Execute by command
sudo docker run –name nginx -d -p 80:80 -v $PWD/nginx/conf:/etc/nginx
The container was created successfully, but could not be started.
Can be seen 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, it is no problem. May I ask why this is, is it a question of authority?
Wow, man, you just killed nginx. Many files of nginx are under /etc/nginx. Don’t mount them like this, just mount one 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 that I choreographed with docker-compose
services: nginx: build: ./dockerfiles/nginx/ container_name: nginx-server ports: - "80:80" links: - "php-fpm" - "webpack-dev-front" volumes: # Site Directory - ./app:/var/www/html - ./dockerfiles/nginx/conf.d:/etc/nginx/conf.d:ro - ./dockerfiles/nginx/nginx.conf:/etc/nginx/nginx.conf:ro # Log File - ./logs/nginx:/var/log/nginx