Pixel Coder
Pixel Coder

Reputation: 329

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.

Here is my docker-compose.yml file :

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?

Upvotes: 1

Views: 2228

Answers (3)

user14896058
user14896058

Reputation:

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

Upvotes: 0

Heinrich Don Z. Abad
Heinrich Don Z. Abad

Reputation: 196

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

Upvotes: 2

Türkalp
Türkalp

Reputation: 188

you should bind to /usr/share/nginx/html your files. It is default location. If you want to change default location, you should change /etc/nginx/conf.d/default.

I prefer use templates via nginx:1.19-alpine.

templates docs

Upvotes: 0

Related Questions