1. 程式人生 > 其它 >nginx 服務部署,對映本地目錄到nginx容器 遇到的問題

nginx 服務部署,對映本地目錄到nginx容器 遇到的問題

技術標籤:dockerlinux

win10的虛擬機器上docker安裝官方映象,首先虛擬機器掛載了本地d:vagrant目錄。掛載本地nginx配置檔案時報錯:

docker run --rm -d -p 8081:80 --name nginx-test \ 
-v /vagrant/my-test/nginx/www:/usr/share/nginx/html \ 
-v /vagrant/my-t est/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \ 
-v /vagrant/my-test/nginx/logs:/var/log/nginx nginx
2832b4d5e319cefc8c7fbe0961b6f23cb047b8c0f86f616ae090183843451240
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/vagrant/my-test/nginx/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/e68d9a7598b5c23f765d2d0acc9ad272d05ef966a6184d526a0470f5be02ec17/merged\\\" at \\\"/etc/nginx/nginx.conf\\\" caused \\\"stat /vagrant/my-test/nginx/conf/nginx.conf: 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.

原因是我在本地目錄上滑鼠右鍵建立的資料夾conf,docker裡面說它不是檔案壓。太菜不知道為啥,於是docker內命令建立 mkdir conf ,在複製一份配置檔案。www裡面整個index.html。瀏覽器訪問 OK!