透過指令執行
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