Docker for windows mount the file to the directory Nginx stepped pit small note

Introduction: Because Docker recent study, by the document rookie tutorial, learn Docker when installing Nginx, encountered an error when running mount directory container, has not run up, wasted a lot of time here in the middle of recording solutions

Related Tutorials:

Rookie tutorial
This tutorial is rookie running code:

$ docker run -d -p 8082:80 --name runoob-nginx-test-web -v ~/nginx/www:/usr/share/nginx/html -v ~/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v ~/nginx/logs:/var/log/nginx nginx

Stepped pit

According to the command tutorial rookie running code, because it is a directory command on Linux tutorial, then my own brain pumping up of the brain commands into the Windows directory:

docker run -D -p 8082: 80 --name runoob nginx web-test -V E: / nginx / www: / Sr / share / nginx / html -V E: /nginx/conf/nginx.conf: / etc / nginx / nginx.conf -V E: / nginx / logs: / var / log / nginx nginx

First wrestle:

Then given:

docker: Error response from daemon: open \.\pipe\docker_d4w_systray: The syThe system cannot find the file specified

Error Analysis

After proper way translation , the system can not find the file, that there may be a routing problem, then online search problem Docker mount path on Windows, and found that a lot of the pit.

climb up

Internet search for a solution, we use the following method found this to write:

docker run -d -p 8082:80 --name runoob-nginx-test-web -v //E/nginx/www:/usr/share/nginx/html -v //E/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v //E/nginx/logs:/var/log/nginx nginx

Second wrestle

This time, the above did not make that mistake, but yet there is a new problem, but added the implementation of container, but did not run, and there is an error message:

OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/E/PHPSpace/docker/nginx/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/69414be2b2572a590e7ee33cc8765f431e8a354100090e802d78888a85834862/merged\\\" at \\\"/var/lib/docker/overlay2/69414be2b2572a590e7ee33cc8765f431e8a354100090e802d78888a85834862/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

Error Analysis

  1. In short, to the effect that I should not be put on file to mount a directory or file to mount the directory, and then I went online found the answer: My nginx.conf may be a folder to be deleted again Create a file type nginx.conf;
  2. But I nginx.conf here is indeed a file, but also come from nginx container copy, and then went on to find a solution, to find a long time, has said that the new file in the C drive, tried, does not work, finally found there is a Docker for Windows desktop applications Docker Desktop file after startup problems mount path can be set.

Resolve Error

Then take chances, I opened the gray icon Docker, click on Settings, enter the Shared Drivers settings page inside, check the E drive, which preserves need to log the user name of the Windows system, then find Nima I actually did not set a password, then ran to set a password, the process:

  • Windows + R, control.exe input into the control panel, select the user account;
  • Click on the user account again, choose to manage other accounts go after;
  • Then there set a password on the line.

After everything is OK, I run a command:
Docker RUN -d -p 8082: 80 --name runoob the Test-Web-nginx--v // E / nginx / the WWW: / usr / report this content share / nginx / HTML -v //E/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v // E / nginx / logs : / var / log / nginx nginx

The result is still the same error, you can not mount the file or directory to the directory can not mount the file.

Vista

Hearts of desperation, I suddenly saw Shared Drivers sentence below code hints, you can use the Windows C: / xxx this command, and then I changed this command tried it, actually ran up:

docker run -d -p 8082:80 --name runoob-nginx-test-web -v E:/PHPSpace/docker/nginx/www:/usr/share/nginx/html -v E:/PHPSpace/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v E:/PHPSpace/docker/nginx/logs:/var/log/nginx nginx

This is the first step on this pit lesson, make a note of hope do not forget it

Reproduced in: https: //juejin.im/post/5d0746f46fb9a07ebd48d656

Guess you like

Origin blog.csdn.net/weixin_33860528/article/details/93179590