Docker Hello Wold – oci runtime error

I am trying to understand Docker and I have a very simple Dockerfile at ~/dockerfiles/test on my OSX.

FROM scratch
RUN echo "Hello world" > ~/helloworld.txt
CMD ["cat", "~/helloworld.txt"]

When I try to build an image for this file like

  • dotnet core app not writing to WebDAV from docker container
  • docker volume custom mount point [duplicate]
  • Can't run Docker container from image after commit
  • Docker Compose run a command
  • Docker for windows not working after install
  • docker jboss7 war commit. Server boot failed in an unrecoverable manner
  • docker build -t simple .
    

    I get an error during the build process.

    Error Output

    Sending build context to Docker daemon 2.048 kB
    Step 1 : FROM scratch
     ---> 
    Step 2 : RUN echo "Hello world" > ~/helloworld.txt
     ---> Running in fc772fd39d45
    oci runtime error: exec: "/bin/sh": stat /bin/sh: no such file or directory
    

    Any pointers on why I am facing this issue?

  • Can I mount a volume from a Dockerfile?
  • Docker will not attach to an image
  • Docker, docker-compose, networking: how to configure?
  • How to wait till POST request is finished in GO?
  • Exposing spring boot random server port using docker
  • Docker & nginx operation not permitted
  • One Solution collect form web for “Docker Hello Wold – oci runtime error”

    You start from SCRATCH (the empty image), you are using cat, which is not a shell built-in.

    cat needs /bin/sh to run (it will fork the process and load dynamic libraries)


    Note: By default, ENTRYPOINT is /bin/sh -c, but the doc “Creating a simple base image using scratch” shows that ENTRYPOINT is empty for a scratch image.

    As BMitch comments below:

    The quick fix to the problem is changing from to something like FROM debian:latest or even FROM busybox:latest if size matters

    The image currently used for that is alpine

    FROM alpine:3.4
    

    The image is only 5 MB and has access to a package repository that is much more complete than other BusyBox based images.

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