Starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown

Mehraj Malik

I want to understand how CMD and ENTRYPOINT works. So, I just created a very simple Dockerfile

FROM scratch

CMD echo "Hello First"

ENTRYPOINT echo "Hello second" 

Then I build image of this :

docker build -t my_image .

The logs are as below:

Step 1/3 : FROM scratch ---> Step 2/3 : CMD echo "Hello First" ---> Using cache ---> 9f2b6a00982f Step 3/3 : ENTRYPOINT echo "Hello second" ---> Using cache ---> 1bbe520f9526 Successfully built 1bbe520f9526 Successfully tagged my_image:latest SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context w ill have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

When I create a container of this image it returns:

docker run my_image

Error is:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/bin/sh\": stat /b in/sh: no such file or directory": unknown.

Can someone please help me about error?

David Maze

There are two things happening here.

A Dockerfile that starts FROM scratch starts from a base image that has absolutely nothing at all in it. It is totally empty. There is not a set of base tools or libraries or anything else, beyond a couple of device files Docker pushes in for you.

The ENTRYPOINT echo ... command gets rewritten by Docker into ENTRYPOINT ["/bin/sh", "-c", "echo ..."], and causes the CMD to be totally ignored. Unless overridden with docker run --entrypoint, this becomes the main process the container runs.

Since it is a FROM scratch image and contains absolutely nothing at all, it doesn't contain a shell, hence the "/bin/sh: no such file or directory" error.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

starting container process caused "exec: \"/app\": permission denied": unknown

starting container process caused "exec: > \"exec\": executable file not found in $PATH": unknown

Error running docker container: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown

starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown

Starting container process caused "exec: \"/tmp/run.sh\": permission denied": unknown

Docker Go image: starting container process caused: exec: "app": executable file not found in $PATH: unknown

Container ECS EC2 not starting with `running exec setns process for init caused \"exit status 23\"": unknown`

starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown

OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"xxxx\": executable file not found in $PATH": unknown

OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-it\": executable file not found in $PATH":unknown

Hyperledger - container_linux.go:349 starting container process caused "no such file or directory": unknown

docker run results in starting container process caused "exec: \"./boot.sh\": permission denied

Starting container process caused "exec: \\"tail -f /dev/null\\": stat tail -f /dev/null: no such file or directory

Error: Starting container process caused "exec: \"/docker-entrypoint.sh\": permission denied"

starting container process caused "exec: \"/tmp/installer.sh\": permission denied"

starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory":

Running a docker Image of Golang failed, with error 'starting container process caused: exec: "/path": permission denied'

Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python":

Debug Golang in containers with delve: container_linux.go:380: starting container process caused: exec: "/dlv": stat /dlv: no such file or directory

starting container process caused: exec: "/bin/sh": stat /bin/sh: no such file or directory ---- executor failed running [/bin/sh -c

Weird Error in kubernetes: "starting container process caused "exec: \"/usr/bin/dumb-init\": stat /usr/bin/dumb-init: no such file or directory"

OCI runtime exec failed: exec failed: container_linux.go:344: starting container process

Cannot start service prometheus: oci runtime error: container_linux.go:235: starting container process caused "container init exited prematurely"

Docker Error response from daemon: OCI runtime create failed container_linux.go:380: starting container process caused

cannot create /etc/nginx/nginx.conf: Directory nonexistent and starting container caused "exec: \"supervisord\": executable file not found in $PATH"

Frequent peaks of CPU, caused by unknown java process

OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown

docker buildx "exec user process caused: exec format error"

Docker Error: OCI runtime create failed: runc create failed: unable to start container process: exec: ".": executable file not found in $PATH: unknown