linux - docker creates nginx container, why can't the nginx.conf file be shared?
迷茫
迷茫 2017-05-27 17:44:12
0
1
930

Execute via command

sudo docker run --name nginx -d -p 80:80 -v $PWD/nginx/conf:/etc/nginx
nginx

The container was created successfully, but could not be started.

You can see it through the log
`
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)
`

If I share the /etc/nginx/conf.d directory, there is no problem. May I ask why this is happening? Is it a permissions issue?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
淡淡烟草味

Wow, buddy, you just killed nginx. Many files of nginx are under /etc/nginx. Don’t mount them like this, just mount a file directly

$sudo docker run --name nginx -d -p 80:80 -v $PWD/nginx/nginx.conf:/etc/nginx/nginx.conf:ro nginx

The following is an example of my arrangement using 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!