通过命令执行
sudo docker run --name nginx -d -p 80:80 -v $PWD/nginx/conf:/etc/nginx
nginx
容器创建成功,但是无法启动.
通过日志可以看见
`
2017/05/24 12:13:34 [emerg] 1#1: open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
`
如果我共享的是/etc/nginx/conf.d目录是没问题的。请问这是为什么,是权限的问题吗?
淡淡烟草味2017-05-27 17:46:12
哇,哥们,你直接把nginx给干掉啦。nginx的很多文件都在/etc/nginx下,别这么挂载,直接挂载一个文件就行了
$sudo docker run --name nginx -d -p 80:80 -v $PWD/nginx/nginx.conf:/etc/nginx/nginx.conf:ro nginx
下面是我用docker-compose编排得例子
services:
nginx:
build: ./dockerfiles/nginx/
container_name: nginx-server
ports:
- "80:80"
links:
- "php-fpm"
- "webpack-dev-front"
volumes:
#网站目录
- ./app:/var/www/html
- ./dockerfiles/nginx/conf.d:/etc/nginx/conf.d:ro
- ./dockerfiles/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
#日志文件
- ./logs/nginx:/var/log/nginx