简体   繁体   English

如何将文件夹挂载到nginx公用文件夹

[英]How to mount a folder into nginx public folder

I have a directory in the host and I want to mount it to a container and to Nginx public folder which is a container itself.我在主机中有一个目录,我想将它安装到一个容器和 Nginx 公共文件夹,它本身就是一个容器。

Here is my docker-compose.yml file:这是我的 docker-compose.yml 文件:

version: "3.3"
services:
    nodeserver:
        build:
            context: ./app
        volumes:
            - /client-images:/usr/src/app/client-images
        ports:
            - "9000:9000"
    nginx:
    restart: always
        build:
            context: ./nginx
        ports:
            - "80:6000"
    db:
        image: mariadb
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: my_secret_mysql_password
    phpmyadmin:
        image: phpmyadmin
        restart: always
        ports:
            - "8080:80"
        environment:
            - PMA_ARBITRARY=1
volumes:
  images:

My images are located in the /client-images directory but how can I mount them to Nginx public directory and access them?我的图像位于 /client-images 目录中,但如何将它们挂载到 Nginx 公共目录并访问它们?

    nginx:
        restart: always
            build:
                context: ./nginx
            ports:
                - "80:6000"
            volumes:
                - '/client-images:/usr/share/nginx/html'

you should bind to /usr/share/nginx/html your files.你应该绑定到/usr/share/nginx/html你的文件。 It is default location.这是默认位置。 If you want to change default location, you should change /etc/nginx/conf.d/default .如果你想改变默认位置,你应该改变/etc/nginx/conf.d/default

I prefer use templates via nginx:1.19-alpine .我更喜欢通过nginx:1.19-alpine使用模板。

templates docs模板文档

nginx: restart: always build: context: ./nginx ports: - "80:6000" volumes: - '/client-images:/usr/share/nginx/html'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM