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

  • Connecting to Oracle XE running on Docker
  • Can't run Raspbian container on docker
  • What is the best way to manage cert/key for Docker containers that must talk TLS
  • Docker IIS Network Connection to External Network
  • gsutil: Unable to find the server at www.googleapis.com
  • Jenkins inside a Docker container
  • 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?

  • Share Same resource in multiple Container in docker
  • Host verification failed error when running git clone inside dockerfile on AWS EC2 instance as host and a private git repository
  • Keep a self hosted servicestack service open as a docker swarm service without using console readline or readkey
  • docker-compose psql could not connect to server
  • Deploying Docker Data Volumes
  • 404 on Nginx running on docker (uwsgi)
  • 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.