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!