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

  • ReactJs development on docker container
  • org.apache.spark.SparkException: Job aborted due to stage failure with Yarn and Docker
  • Copy a folder into a mounted volume within a Docker Container
  • What does Docker Quickstart Terminal do?
  • Create multiple Docker network connections
  • Docker: how to use SQL file in Directory
  • 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?

  • Which Official Docker Image(s) should I use for running an application with multiple dependencies?
  • Updating rather than replacing ECS Task Definition with CloudFormation
  • Heroku: Dockerized Rails API Deploying
  • ADD command failing while building dockerfile using docker-build-step plugin in jenkins
  • What does 'Logging' do in
  • Configure Dockerfile to use impdp command when the container is created
  • 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.