php - docker-compose mounting issue
阿神
阿神 2017-05-18 10:47:00
0
2
617

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

阿神
阿神

闭关修行中......

reply all(2)
为情所困

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?

# 容器的/docker/nginx/www目录挂载主机中的/usr/share/nginx/html目录
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template