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):

  • How to use Docker Remote API to assign a static IP address to a container
  • Install SCP in Docker container
  • docker permission for a container in /sys/fs/cgroups/devices
  • Docker and Rails environments
  • Communicating between Docker containers in different networks on the same host
  • Piping contents to docker image
  • 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

    Actually /bin/sh exists and, in fact, if I run CMD ["/bin/sh"] I don’t get any error. Can anyone help me here?

  • Nexus 3 Docker container and Backup
  • Docker daemon wont start , do i need something configuration before?
  • docker not found with docker:dind + google/cloud-sdk
  • docker container exits immediately even with Console.ReadLine() in a .net core console application
  • Running multi-node kubernetes using docker
  • docker swarm 1.2.0 reschedule with port mapping
  • 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, and /bin/sh is in the tar archive… chances are that archive didn’t uncompress properly.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.