Error Docker Build
AlexVanMechelen opened this issue · comments
Command used
docker build -t dhondta/packing-box .
ERROR [framework 10/20]
[...]
=> [framework 3/20] COPY --chown=user src/files/utils/* /home/user/.opt/utils/ 0.1s
=> [framework 4/20] COPY --chown=user src/files/tools/* /home/user/.opt/tools/ 0.1s
=> [framework 5/20] RUN mv /home/user/.opt/tools/help /home/user/.opt/tools/? 0.5s
=> [framework 6/20] COPY --chown=user src/data /home/user/.packing-box/data 0.1s
=> [framework 7/20] COPY --chown=user src/lib /tmp/lib 0.1s
=> [framework 8/20] RUN pip3 install --user --no-warn-script-location --break-system-packages /tmp/lib/ && rm 79.8s
=> [framework 9/20] COPY --chown=user src/files/analyzers/* /tmp/analyzers/ 0.2s
=> ERROR [framework 10/20] RUN find /tmp/analyzers -type f -executable -exec mv {} /home/user/.opt/bin/ ; && /h 0.6s
------
> [framework 10/20] RUN find /tmp/analyzers -type f -executable -exec mv {} /home/user/.opt/bin/ ; && /home/user/.opt/tools/packing-box setup analyzer:
0.549 /bin/sh: 1: /home/user/.opt/tools/packing-box: not found
------
Dockerfile:165
--------------------
164 | COPY --chown=$USER $FILES/analyzers/* /tmp/analyzers/
165 | >>> RUN find /tmp/analyzers -type f -executable -exec mv {} $UOPT/bin/ \; \
166 | >>> && $PBOX setup analyzer
167 | # install detectors (including wrapper scripts)
--------------------
ERROR: failed to solve: process "/bin/sh -c find /tmp/analyzers -type f -executable -exec mv {} $UOPT/bin/ \\; && $PBOX setup analyzer" did not complete successfully: exit code: 127
Issue on this line:
RUN find /tmp/analyzers -type f -executable -exec mv {} $UOPT/bin/ \; \
&& $PBOX setup analyzer
Issue
/home/user/.opt/tools/packing-box: not found
Update
I removed some of the build steps that caused an error to be able to build a partial container and investigate.
In Dockerfile:
[...]
# install analyzers
COPY --chown=$USER $FILES/analyzers/* /tmp/analyzers/
#RUN find /tmp/analyzers -type f -executable -exec mv {} $UOPT/bin/ \; \
# && $PBOX setup analyzer
# install detectors (including wrapper scripts)
COPY --chown=$USER $FILES/detectors/* /tmp/detectors/
#RUN find /tmp/detectors -type f -executable -exec mv {} $UOPT/bin/ \; \
# && find /tmp/detectors -type f -iname '*.txt' -exec mv {} $UOPT/detectors/ \; \
# && $PBOX setup detector
# install packers
COPY --chown=$USER $FILES/packers/* /tmp/packers/
#RUN $PBOX setup packer
# install unpackers
#COPY ${FILES}/unpackers/* /tmp/unpackers/ # leave this commented as long as $FILES/unpackers has no file
#RUN $PBOX setup unpacker
# geenerate Bash completions
#COPY --chown=$USER $FILES/utils/_pbox-compgen $UOPT/utils/
#COPY --chown=$USER $FILES/utils/pbox-completions.json $UOPT/utils/
#RUN $UOPT/utils/_pbox-compgen $UOPT/utils/pbox-completions.json -f $HOME/.bash_completion
# ----------------------------------------------------------------------------------------------------------------------
RUN find $UOPT/bin -type f -exec chmod +x {} \;
ENV UOPT=$UOPT
#ENTRYPOINT $UOPT/tools/startup
WORKDIR /mnt/share
The container now builds and the file that caused the "not found" error seems to be present /home/user/.opt/tools/packing-box
The problem however is that this file can't execute. It starts with a shebang line to /bin/bash, and upon testing I can't run /bin/bash either, due to an error in /home/user/.bashrc
bash: /home/user/.bashrc: line 6: syntax error near unexpected token `elif'
'ash: /home/user/.bashrc: line 6: ` elif [ -f /etc/bash_completion ]; then
Don't know why this gives an error, as it seems correct syntax.
Commenting it out to see if that fixes the error, a new error occurs.
bash: /home/user/.bashrc: line 13: syntax error near unexpected token `$'{\r''
'ash: /home/user/.bashrc: line 13: ` function command_not_found_handle {
@AlexVanMechelen Thank you for mentioning this. Please provide more information about the environment on which you are trying to build the box (platform, Docker version, etc).
@AlexVanMechelen Your very first error seems to relate to an issue with a COPY in the Dockerfile
when building the box in Windows. The second one indicates an issue with a carriage return (Linux uses newlines \n
and Windows uses CRLF \r\n
) in .bashrc
. If you manage to start the box, you can dos2unix ~/.bashrc
.