我正在尝试在docker容器中运行Nginx,同时挂载配置和静态HTML文件以供它使用.据我所知,非常简单的东西,但我不断收到关于目录不是目录的错误?
我正在使用最新版本的Boot2Docker在我的Mac上运行此示例.
% tree ~/Projects/Docker/Nginx-example
.
├── html
│ └── test.html
└── Nginx.conf
1 directory, 2 files
http {
server {
listen *:80; # Listen for incoming connections from any interface on port 80
server_name ""; # Don't worry if "Host" HTTP Header is empty or not set
root /usr/share/Nginx/html; # serve static files from here
}
}
我尝试运行容器(在〜/ Projects / Docker / Nginx-example目录中),如下所示:
docker run --name Nginx-container \
-v /Users/M/Projects/Docker/Nginx-example/html:/usr/share/Nginx/html:ro \
-v /Users/M/Projects/Docker/Nginx-example/Nginx.conf:/etc/Nginx:ro \
-P -d Nginx
Originally I had tried something like
-v $(pwd)/html:/usr/share/Nginx/html:ro
to keep the command shorter, but when it didn’t work I thought I’d be explicit just in case there was some funky sub shell issue I wasn’t aware of
我得到以下输出
fc41205914098d236893a3b4e20fa89703567c666ec1ff29f123215dfbef7163
Error response from daemon:
Cannot start container fc41205914098d236893a3b4e20fa89703567c666ec1ff29f123215dfbef7163:
[8] System error: not a directory
有没有人知道我错过了什么?
Mac Boot2Docker卷问题?
我知道在使用Boot2Docker时将卷装入容器存在问题(尽管我认为这已经很久以来已经解决了)
即Mount volume to Docker image on OSX
但我无论如何都遵循那里的指示,但仍然没有奏效
解决方法:
-v /Users/M/Projects/Docker/Nginx-example/Nginx.conf:/etc/Nginx:ro
您正在尝试将文件挂载到目录 – 将其更改为:
-v /Users/M/Projects/Docker/Nginx-example/Nginx.conf:/etc/Nginx/Nginx.conf:ro你应该没问题.看一下Docker Volumes Docs中的例子
同样,pwd应该在路径上工作. shell在运行docker命令之前扩展它,就像数学和内括号一样,首先运行内部子命令.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。