basickarl
basickarl

Reputation: 40561

OCI runtime create failed: container_linux.go:296 - no such file or directory

End of my Dockerfile:

ENTRYPOINT ["ls /etc"]

Terminal:

...Rest of the building  above is fine
Step 8/8 : ENTRYPOINT ["ls /etc"]
 ---> Using cache
 ---> ea1f33b8ab22
Successfully built ea1f33b8ab22
Successfully tagged redis:latest
k@Karls ~/dev/docker_redis (master) $ docker run -d -p 6379:6379 --name red redis
71d75058b94f088ef872b08a115bc12cece288b53fe26d67960fe139953ed5c4
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"ls /etc\": stat ls /etc: no such file or directory": unknown.

For some reason, it won't find the directory /etc. I did a pwd and the current working directory is /. I also did a ls / on the entrypoint and that displayed the /etc directory fine.

Upvotes: 18

Views: 31683

Answers (5)

BMitch
BMitch

Reputation: 265150

The command you are trying to execute inside the container does not exist. In this case ls /etc does not exist in the image. There's a /bin/ls binary, but not a /bin/"ls /etc" binary, which itself would be invalid since the name of a file on the filesystem cannot include a /, though it can include a space.

Of course what you wanted to run was ls with the argument /etc, and for that, you need to separate each argument if you run with the exec syntax.

ENTRYPOINT ["ls", "/etc"]

Or if you wanted to allow a shell to parse the string, same way as if you were at a bash prompt inside the container running ls /etc on the command line, then switch to the string syntax that runs a shell:

ENTRYPOINT ls /etc

Upvotes: 1

medo
medo

Reputation: 11

I've expirienced the same issue after updating my Windows credentials, try following: Docker settings > Shared Drives > Reset credentials > Select drives again > Apply and re-enter your credentials. This solved the problem for me multiple times

Upvotes: 1

nikk wong
nikk wong

Reputation: 8690

On OSX, I fixed it by clearing the volume data manually. Close docker, and remove everything in ~/Library/Containers/com.docker.docker

Upvotes: 1

user1522263
user1522263

Reputation: 113

I appear to be having the same issue. Here is what I am doing.

Dockerfile

FROM gcc:7.2.0
COPY  src/ /usr/src/myapp
WORKDIR /usr/src/myapp
RUN set -x gcc -o myapp main.c
CMD ["./myapp"]

Build

$ docker build -t test .
Sending build context to Docker daemon  3.584kB
Step 1/6 : FROM gcc:7.2.0
...
 ---> 3ec35c7d2396
Successfully built 3ec35c7d2396
Successfully tagged test: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 
will have '-rwxr-xr-x' permissions. It is recommended to double check and 
reset permissions for sensitive files and directories.

Run

$ docker run -it test
D:\Docker Toolbox\docker.exe: Error response from daemon: OCI runtime create 
failed: container_linux.go:296: starting container process caused "exec: 
\"./myapp\": stat ./myapp: no such file or directory": unknown.

Changed CMD to ENTRYPOINT and removed the set -x seemed to resolve the problem. Though we are still unsure what the cause was or if this will also work for you. Make sure that /etc exists or is created as the main.c wasn't compiling.

Dockerfile

FROM gcc:7.2.0
COPY  src/ /usr/src/myapp
WORKDIR /usr/src/myapp
RUN gcc -o myapp main.c
ENTRYPOINT ["./myapp"]

Upvotes: 3

ZeissS
ZeissS

Reputation: 12135

OCI runtime create failed: container_linux.go:296

In my experience this is an error with the docker daemon itself, not the container you are trying to run. Try deleting all containers, restarting the daemon. I think we also had to clean up the docker networks.

Upvotes: 9

Related Questions