cli icon indicating copy to clipboard operation
cli copied to clipboard

docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "open /proc/self/fd: no such file or directory".

Open ghost opened this issue 9 years ago • 70 comments

Description

Steps to reproduce the issue:

  1. docker build
FROM nginx
MAINTAINER suiwenfeng <[email protected]>

# add config to 
# copy ./default.conf /etc/nginx/conf.d

VOLUME [".","/usr/share/nginx/html"]

CMD ["nginx", "-g", "daemon off;"]
  1. docker rm -f {containerid}
  2. docker volume rm $(docker volume ls -qf dangling=true)

Describe the results you received:

docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "open /proc/self/fd: no such file or directory".

throw the same error for each docker run , and docker run failed.

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Docker version 17.06.0-ce, build 02c1d87

Output of docker info:

Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 7
Server Version: 17.06.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.31-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: moby
ID: AX4D:5GVQ:SDCP:PFA2:BJFW:Y3RJ:YYCB:QWV7:UW4B:U5BF:5UJB:CZHF
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 19
 Goroutines: 34
 System Time: 2017-07-05T08:02:41.906145547Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

ghost avatar Jul 05 '17 08:07 ghost

i have tried reset docker deamon, it not work.

ghost avatar Jul 05 '17 08:07 ghost

not working even after restart the computer.

ghost avatar Jul 05 '17 08:07 ghost

looks some symlink removed from /dev, and the mobylinux crashed? so i have to reinstall docker?

ghost avatar Jul 05 '17 08:07 ghost

same issue, running same version and on Fedora 25 here too.

lpegoraro avatar Jul 15 '17 10:07 lpegoraro

https://github.com/docker/for-linux/issues is probably a better place to report this issue. I don't believe this is related to the cli.

dnephin avatar Jul 19 '17 16:07 dnephin

Isn't this because you try to define the volume twice? This volume is already defined in the nginx docker file.

If I mount the volume on run it works "docker run -d -p 80:80 -v $PWD:/usr/share/nginx/html nginx"

supernelis avatar Oct 09 '17 09:10 supernelis

same error, same arm64, same docker version

bitliubei avatar Nov 29 '17 08:11 bitliubei

VOLUME [".","/usr/share/nginx/html"]

@suiwenfeng What exactly are you trying to do with that line? Using the JSON notation for VOLUME in this case attempts to define two volumes; one at "." (current working-directory), and one at "/usr/share/nginx/html" (which is already defined as a volume in the base image)

The first (".") is what's causing the issue here, because the working-dir for the nginx image is /, which effectively would try to create a volume for the whole container (which isn't allowed / won't work). You can find the current working-directory for the image using the following;

$ docker run --rm nginx pwd
/

Interesting bit here, is that there is some validation in the daemon, but it's missing validation for certain cases. For example, these Dockerfiles all build without producing an error during build;

FROM nginx
VOLUME ["/"]
FROM nginx
VOLUME /
FROM nginx
VOLUME ["."]
FROM nginx
VOLUME .

But starting a container from any of the above (as expected) won't work;

docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"open /dev/ptmx: no such file or directory\"": unknown.

When defining a volume at runtime, the following correctly produces a validation error;

$ docker run -it --rm -v myvolume:/ nginx 
docker: Error response from daemon: invalid volume specification: 'myvolume:/': invalid mount config for type "volume": invalid specification: destination can't be '/'.
See 'docker run --help'.

But only specifying the "container path" does not perform the correct validation, thus results in the same "cryptic" error;

$ docker run -it --rm -v / nginx
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"open /dev/ptmx: no such file or directory\"": unknown.

thaJeztah avatar Dec 26 '17 22:12 thaJeztah

I opened https://github.com/moby/moby/issues/35879 for tracking this in the Moby repository (where this validation should be performed). Given that this is not a bug in the CLI, and the bug is missing validation for these cases (the Dockerfile is actually incorrect), I'm closing the issue here, but feel free to continue the conversation

thaJeztah avatar Dec 26 '17 22:12 thaJeztah

Same problem on docker-ce within jenkins container, running on Windows 10 host (inception):

docker run -d --name test.nginx -p 90:80 -p 554:443 --network graphityplatform_default --network-alias test.nginx -v /var/jenkins_home/workspace/docker-platform_stage.localhost_/docker/nginx-frontend/nginx.test.conf:/etc/nginx/nginx.conf nginx
docker: Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"rootfs_linux.go:58: mounting \\\"/var/jenkins_home/workspace/docker-platform_stage.localhost_/docker/nginx-frontend/nginx.test.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/81cb11389790f97d5026133a05e4f555d499963dd614e082072276ca6a362bc6/merged\\\" at \\\"/var/lib/docker/overlay2/81cb11389790f97d5026133a05e4f555d499963dd614e082072276ca6a362bc6/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
def81c6ffdf5f699517b2908d6a96ca40551646c4a965cef2be561c9cffd6433

namedgraph avatar Jan 21 '18 01:01 namedgraph

Any solutions on this error ?

IvanAdji avatar Feb 28 '18 09:02 IvanAdji

@pumba-lt your error looks different; from the error (copied the important parts below):

mounting "/var/jenkins_home/workspace/docker-platform_stage.localhost_/docker/nginx-frontend/nginx.test.conf" to rootfs 
at "/var/lib/docker/overlay2/81cb11389790f97d5026133a05e4f555d499963dd614e082072276ca6a362bc6/merged/etc/nginx/nginx.conf"
caused "not a directory """: unknown: 
Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

That error indicates that likely the nginx.test.conf file did not exist on the daemon host. If you were attempting to mount a file using the -v <host-path>:<container-path> option, and <host-path> doesn't exist on the daemon host, docker will assume you want to bind-mount a directory, and create the directory if it doesn't exist. It then bind-mounts the directory in the container at <container-path>, which will fail if <container-path> is a file (because you cannot mount a directory on top of a file). That's the last part of the error message:

Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
  • check if the file /var/jenkins_home/workspace/docker-platform_stage.localhost_/docker/nginx-frontend/nginx.test.conf exists on the daemon host
  • if it didn't exist, docker now created a directory at the path above; remove that directory and replace it with the file you're trying to mount
  • you can also use the --mount flag instead of -v / --volume: the --mount flag will not automatically create a directory if the host-path is missing, but instead produce an error, so that you're aware the path (file/directory) on the host is missing.

Bind-mounting always happens from the host where the daemon runs, so even though the file may be present on your "client" machine; if that machine is a local machine, and not the machine where the daemon runs, bind-mounting won't work.

Also note that if you are running docker-in-docker, the "daemon host" may be the container in which the daemon is running.

thaJeztah avatar Feb 28 '18 10:02 thaJeztah

@akivanctp the original error reported is an invalid volume path (/ cannot be used as a volume). For other situations, see my comment above: TL;DR make sure that, when using bind-mounts, the path that you're trying to mount exists.

thaJeztah avatar Feb 28 '18 10:02 thaJeztah

any solution for this issue ? oci runtime error: container_linux.go:265: starting container process caused "exec:

atiasadir avatar Nov 12 '18 17:11 atiasadir

Any solution?? https://hjlabs.in/

hemangjoshi37a avatar Dec 27 '18 20:12 hemangjoshi37a

same with "Version 2.0.0.0-mac78 (28905)" I've tried reset to factory settings but still got:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-d\": executable file not found in $PATH": unknown.

jzlocz avatar Dec 28 '18 11:12 jzlocz

@jakubzloczewski double-check the exact command you're running to start your container; from that output, it looks like you passed the -d option after the name of the image you're trying to run. Because of that, -d is used as the command to run inside the container, thus will fail;

docker run busybox -d
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-d\": executable file not found in $PATH": unknown.

The -d (--detach) option is an option for docker run, so must be passed before the name of the image you're running;

docker run -d busybox

thaJeztah avatar Dec 28 '18 11:12 thaJeztah

I have a similar issue, when I tried to install elasticsearch on my personal laptop, I execute

docker run --name=amp-es -d -v ~/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -p 9200:9200 -p 9300:9300 --network=amp-network elasticsearch:2.4

then got the same error:

Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/cliu426/elasticsearch.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/53adcd81e2c00ea1f7b40ee67b5ae62ae6d80afbb939b57ef48adf37d003f7fd/merged\\\" at \\\"/var/lib/docker/overlay2/53adcd81e2c00ea1f7b40ee67b5ae62ae6d80afbb939b57ef48adf37d003f7fd/merged/usr/share/elasticsearch/config/elasticsearch.yml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Error: failed to start containers: amp-es

Liuchengda avatar Jan 10 '19 11:01 Liuchengda

@Liuchengda Not the same error (cleaned up the error for readability);

mounting "/Users/cliu426/elasticsearch.yml" to rootfs "/var/lib/docker/overlay2/53adcd81e2c00ea1f7b40ee67b5ae62ae6d80afbb939b57ef48adf37d003f7fd/merged"
at "/var/lib/docker/overlay2/53adcd81e2c00ea1f7b40ee67b5ae62ae6d80afbb939b57ef48adf37d003f7fd/merged/usr/share/elasticsearch/config/elasticsearch.yml"
caused "not a directory": unknown:

Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

That last line is the actual error; you're trying to mount a local file or directory from your host (/Users/cliu426/elasticsearch.yml) into the container (at /usr/share/elasticsearch/config/elasticsearch.yml). However, the path on your host cannot be found, or is a directory;

  • Check if the file /Users/cliu426/elasticsearch.yml exists
    • When using the -v option; docker creates a directory at the given location if the file/path does not exist
  • Note that bind-mounting is done from the host that the daemon runs on, and thus won't work if the daemon is running remotely ("remotely" could be a Virtual Machine)

thaJeztah avatar Jan 10 '19 12:01 thaJeztah

For me the error occurred when I was trying to execute command to run my startup script command: bash startup.sh. Problem was that my image build was made on alpine linux which uses ash as shell instead of bash. Just double check that you are referring to correct shell interpreter.

ldynia avatar Jan 18 '19 15:01 ldynia