docker build errors are hard to identify
pablomuri opened this issue · 7 comments
if a docker build fails during a RUN
command, the output of the docker build will just show that this line has failed. The problem is that we have a RUN
command with appended bash commands, we can't know which of the appended commands have failed.
Example of an error:
[2023-12-13 17:02:23] Step 15/16 : RUN wget -q https://github.com/OpenTSDB/opentsdb/releases/download/v2.3.0/opentsdb-2.3.0_all.deb && apt-get update -q && apt-get install -yq --no-install-recommends gnuplot gcc && python3 -m pip install happybase==1.2.0 && dpkg -i opentsdb-2.3.0_all.deb && chmod 777 /app/* && rm -rfv /var/lib/apt/lists/* /tmp/* /var/tmp/*
[2023-12-13 17:02:23] ---> Running in 433c224e8e2c
[2023-12-13 17:02:25] The command '/bin/sh -c wget -q https://github.com/OpenTSDB/opentsdb/releases/download/v2.3.0/opentsdb-2.3.0_all.deb && apt-get update -q && apt-get install -yq --no-install-recommends gnuplot gcc && python3 -m pip install happybase==1.2.0 && dpkg -i opentsdb-2.3.0_all.deb && chmod 777 /app/* && rm -rfv /var/lib/apt/lists/* /tmp/* /var/tmp/*' returned a non-zero code: 4
[2023-12-13 17:02:25] generated.mk:8: recipe for target 'build-base' failed
[2023-12-13 17:02:25] make: *** [build-base] Error 4
This is the actual RUN
command that must be separated.
open-kilda/docker/opentsdb/Dockerfile
Lines 23 to 31 in 0713c48
Identify all the possible problematic commands and separate them in order to have a better understanding of the cause when the docker build fails. The most problematic commands usually are the ones that use the network (i.e. apt update, wget/curl, etc) so maybe it is not necessary to separate all of them.
Hi, I want to work on this issue. Can you assign it to me?
@Ashwinn11 , yes, it is a normal kilda behavior. It builds without errors usually.
The issue is about cases when some problems occur.
You can reproduce the problem by, e.g., putting non-existing version of the package or apt flag in RUN command.
The desired behavior is to have one bash command per docker RUN instruction or bash script with exception handlers, not simple line RUN command1 && command2 && command3 && ...
Add also that this issue applies to all the Dockerfiles under the docker/ directory. Not only to docker/opentsdb/Dockerfile
I misunderstood the issue. Now got it! Will work on it👍
most likely the error is related to wget code: 4
- network connection eror
- no left space on device
That is bad practice to do it. https://docs.docker.com/develop/develop-images/instructions/#run. If you need that for debugging is ok. But in the product docker file that will be something strange.
Every RUN
command in docker has its layer. To debug wtf is going on you can use docker run --rm -it $layer_id sh
. In @pablomuri case, it will be 433c224e8e2c
.