Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

docker - Are you trying to mount a directory onto a file (or vice-versa)?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This should no longer happen (since v2.2.0.0), see here


If you are using Docker for Windows, this error can happen if you have recently changed your password.

How to fix:

  1. First make sure to delete the broken container's volume
    docker rm -v <container_name>
    Update: The steps below may work without needing to delete volumes first.
  2. Open Docker Settings
  3. Go to the "Shared Drives" tab
  4. Click on the "Reset Credentials..." link on the bottom of the window
  5. Re-Share the drives you want to use with Docker
  • You should be prompted to enter your username/password
  1. Click "Apply"
  2. Go to the "Reset" tab
  3. Click "Restart Docker"
  4. Re-create your containers/volumes

Credit goes to BaranOrnarli on GitHub for the solution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...