I have a docker with version 17.06.0-ce
. When I trying to install nginx using docker with command:
docker run -p 80:80 -p 8080:8080 --name nginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx:latest
it shows that
docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"rootfs_linux.go:57: mounting \\\"/appdata/nginx/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/aufs/mnt/dcea22444e9ffda114593b18fc8b574adfada06947385aedc2ac09f199188fa0\\\" at \\\"/var/lib/docker/aufs/mnt/dcea22444e9ffda114593b18fc8b574adfada06947385aedc2ac09f199188fa0/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\""
: 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.
If do not mount the nginx.conf
file, everything is okay. So, how can I mount the configuration file?
Thanks.
If you are using Docker for Windows, this error can happen if you have recently changed your password.
How to fix:
docker rm -v <container_name>
Credit goes to BaranOrnarli on GitHub for the solution.
Remove the volumes associated with the container. Find the container name using
docker ps -a
then remove the container using:Problem:
The error you are facing might occur if you tried running
docker run
command previously when file was not present at the location where it should have been in host directory. In this case docker daemon would have created a directory inside container in its place. Which later fails to map to proper file when correct files are put in host directory and docker is run again.Solution:
Remove the volumes that are associated to the container. If you are not concerned about other container volumes, you can also use:
could you please use the absolute path/complete path instead $PWD/conf/nginx.conf .it will work
i know this question was posted long ago
but still i would like to answer how i resolved this issue
Because docker recognize
$PWD/conf/nginx.conf
as folder and not file.Check if
$PWD/conf/
directory does not contain nginx.conf as directory.Try with
Otherwise, open a Docker issue.
It's working fine for me with same configuration.