This is the nginx part of docker-compose.yml. It only mounts the site root directory. The www directory file of the host machine can work normally:
nginx:
depends_on:
- php
# nginx镜像的路径
image: hub.c.163.com/library/nginx:latest
# 宿主机的/docker/nginx/www目录挂载容器中的/usr/share/nginx/html目录,
volumes:
- /docker/nginx/www:/usr/share/nginx/html
# nginx意外退出时自动重启
restart: always
ports:
- "80:80"
- "443:443"
container_name: nginx
But when I mount the Nginx configuration file:
nginx:
depends_on:
- php
# nginx镜像的路径
image: hub.c.163.com/library/nginx:latest
# 宿主机的/docker/nginx/www目录挂载容器中的/usr/share/nginx/html目录,
volumes:
- /docker/nginx/www:/usr/share/nginx/html
- /docker/nginx/conf:/etc/nginx/conf.d
# nginx意外退出时自动重启
restart: always
ports:
- "80:80"
- "443:443"
container_name: nginx
It cannot work normally. I have copied the Nginx configuration file from the previous normal working time to the host/docker/nginx/conf, but it is of no use. Just remove the
of this mount configuration and it will work again
1. If nginx does not mount the nginx file first, then docker exec -it to enter nginx, or mount it to another directory to check whether the file is mounted ok
2. If the host is windows or macos, please check the directory sharing to see if it is correct , generally speaking, projects under Users will be mounted correctly
The following are problems I have encountered before, I hope it will be helpful to you:
/q/10...
Is the path wrong? I looked at my project and it looks like this
- "./nginx.conf:/etc/nginx/conf.d/default.conf"
You can use bash to check the path
Did you write this comment backwards?