Installed rrdtool during build, but not found later in build proces

Hi

Display the docker images right after your build fails.
You should see the image(s) (layers) that were created when the build failed.
The 1st image displayed will be the most recent image (layer) that was being built at the time the build failed.
You can then bring up a container from that image with a shell prompt and debug.

Example:

I’m building a simple HelloWorld C application on the Docker Official Alpine Linux docker image.
The build fails in step 8.

I purposely removed the install for the GCC compiler in my Dockerfile to cause the failure to illustrate how to debug a docker image build failure.

🐳  gforghetti:[~/GitHub/helloworld-c] $ docker image build -t gforghetti/helloworld-c:latest .
Sending build context to Docker daemon  8.192kB
Step 1/8 : FROM alpine:latest
latest: Pulling from library/alpine
6c40cc604d8e: Pull complete
Digest: sha256:b3dbf31b77fd99d9c08f780ce6f5282aba076d70a513a8be859d8d3a4d0c92b8
Status: Downloaded newer image for alpine:latest
 ---> caf27325b298
Step 2/8 : ARG BUILDDIR="/HelloWorld"
 ---> Running in cc6fda709fc8
Removing intermediate container cc6fda709fc8
 ---> b289a9247989
Step 3/8 : WORKDIR ${BUILDDIR}
 ---> Running in c192af6c7196
Removing intermediate container c192af6c7196
 ---> d4f39eef7593
Step 4/8 : LABEL description="HelloWorld C Application"
 ---> Running in 9e2b59ed4413
Removing intermediate container 9e2b59ed4413
 ---> e1c2e3e97c10
Step 5/8 : LABEL maintainer="Gary Forghetti, Docker Inc."
 ---> Running in 54f8fb0a72e1
Removing intermediate container 54f8fb0a72e1
 ---> be63d49c4440
Step 6/8 : CMD /HelloWorld/HelloWorld
 ---> Running in bec5a073c41e
Removing intermediate container bec5a073c41e
 ---> b402b0207eab
Step 7/8 : COPY ./HelloWorld.c ${BUILDDIR}
 ---> e68c8b34ee79
Step 8/8 : RUN apk update && gcc HelloWorld.c -o HelloWorld && chmod ugo+rx HelloWorld && rm -f HelloWorld.c && apk del gcc libc-dev && { apk cache clean --purge > /dev/null @>&1 || true; }
 ---> Running in e709e3032c43
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
v3.9.0-17-g8b92b92a30 [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.0-16-gfe0ab7c606 [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
OK: 9750 distinct packages available
/bin/sh: gcc: not found
The command '/bin/sh -c apk update && gcc HelloWorld.c -o HelloWorld && chmod ugo+rx HelloWorld && rm -f HelloWorld.c && apk del gcc libc-dev && { apk cache clean --purge > /dev/null @>&1 || true; }' returned a non-zero code: 127

I run a docker image ls command and see that the most recent image (layer) being built was e68c8b34ee79. Notice it has no name because the build failed and it was not tagged.

🐳  gforghetti:[~/GitHub/helloworld-c] $ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              e68c8b34ee79        10 seconds ago      5.53MB
alpine              latest              caf27325b298        9 days ago          5.53MB

So I can now run a container from that image (layer) and bring up a command shell (sh).
I can then run commands inside the shell to debug.

🐳  gforghetti:[~/GitHub/helloworld-c] $ docker container run -it e68c8b34ee79 sh
/HelloWorld # uname -a
Linux 6a7277eb91f5 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 Linux
/HelloWorld # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.9.0
PRETTY_NAME="Alpine Linux v3.9"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/HelloWorld # ls -la
total 12
drwxr-xr-x    1 root     root          4096 Feb  9 18:05 .
drwxr-xr-x    1 root     root          4096 Feb  9 18:28 ..
-rwxr-xr-x    1 root     root          1742 Feb  9 17:34 HelloWorld.c
/HelloWorld # gcc
sh: gcc: not found
/HelloWorld # find / -name gcc*
/HelloWorld #

So I install the GCC compiler and headers and libraries inside the shell

/HelloWorld # apk add gcc libc-dev
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/12) Installing binutils (2.31.1-r2)
(2/12) Installing gmp (6.1.2-r1)
(3/12) Installing isl (0.18-r0)
(4/12) Installing libgomp (8.2.0-r2)
(5/12) Installing libatomic (8.2.0-r2)
(6/12) Installing libgcc (8.2.0-r2)
(7/12) Installing mpfr3 (3.1.5-r1)
(8/12) Installing mpc1 (1.0.3-r1)
(9/12) Installing libstdc++ (8.2.0-r2)
(10/12) Installing gcc (8.2.0-r2)
(11/12) Installing musl-dev (1.1.20-r3)
(12/12) Installing libc-dev (0.7.1-r0)
Executing busybox-1.29.3-r10.trigger
OK: 103 MiB in 26 packages
/HelloWorld #

I can then re-run the command that failed inside the shell by doing a copy/paste.

/HelloWorld # gcc HelloWorld.c -o HelloWorld && chmod ugo+rx HelloWorld && rm -f HelloWorld.c && apk del gcc libc-dev && { apk cache clean --purge > /dev/null @>&1 || true; }
(1/12) Purging gcc (8.2.0-r2)
(2/12) Purging binutils (2.31.1-r2)
(3/12) Purging libatomic (8.2.0-r2)
(4/12) Purging libgomp (8.2.0-r2)
(5/12) Purging libc-dev (0.7.1-r0)
(6/12) Purging musl-dev (1.1.20-r3)
(7/12) Purging mpc1 (1.0.3-r1)
(8/12) Purging mpfr3 (3.1.5-r1)
(9/12) Purging isl (0.18-r0)
(10/12) Purging gmp (6.1.2-r1)
(11/12) Purging libstdc++ (8.2.0-r2)
(12/12) Purging libgcc (8.2.0-r2)
Executing busybox-1.29.3-r10.trigger
OK: 6 MiB in 14 packages

C Compile worked.

/HelloWorld # ls -la
total 28
drwxr-xr-x    1 root     root          4096 Feb  9 18:33 .
drwxr-xr-x    1 root     root          4096 Feb  9 18:28 ..
-rwxr-xr-x    1 root     root         18816 Feb  9 18:33 HelloWorld
/HelloWorld #

I can also run the program.

/HelloWorld # ./HelloWorld
Hello World!
I am running on Linux x86_64.
It is Saturday February 09, 2019 and the time is 06:19:46 PM.
/HelloWorld #

You then fix your Dockerfile and retry your build.