Docker: Unable to execute RUN command after ADD when starting from scratch
I’m trying to build a custom Linux Alpine docker for ARM architecture starting from the “scratch” image. I don’t understand why I can’t execute any RUN command after I execute ADD. This is my Dockerfile:
FROM scratch ADD rootfs.tar / MAINTAINER Vittorio_Cozzolino RUN apk add nodejs
And this is the output that I get when the automated build completes (the last line contains the error):
Client: Version: 1.8.1 API version: 1.20 Go version: go1.4.2 Git commit: d12ea79 Built: Thu Aug 13 02:49:29 UTC 2015 OS/Arch: linux/amd64 Server: Version: 1.8.3-rc1 API version: 1.20 Go version: go1.4.2 Git commit: 6f21aba Built: Mon Sep 28 20:03:03 UTC 2015 OS/Arch: linux/amd64 Step 0 : FROM scratch ---> Step 1 : ADD rootfs.tar / ---> dd771ffd56ea702 Step 2 : MAINTAINER Vittorio_Cozzolino ---> 825fc4c990c8a33 Step 3 : RUN apk add nodejs [91mexec: "/bin/sh": stat /bin/sh: no such file or directory
/bin/sh exists and, in fact, if I run
CMD ["/bin/sh"] I don’t get any error. Can anyone help me here?
One Solution collect form web for “Docker: Unable to execute RUN command after ADD when starting from scratch”
CMD ["/bin/sh"] is a simple declaration of the default command to run, so it will always work.
Check if the tar is indeed unpacked, as there was a similar issue in 9541: limit your Dockerfile to the
ADD directive, and use
docker exec or a simple
ls to see what is in there (and with which owner/permission).
If the Dockerfile complains about a missing
/bin/sh is in the tar archive… chances are that archive didn’t uncompress properly.