how to run nginx docker container with custom config?

前端 未结 3 472
误落风尘
误落风尘 2020-12-29 03:36

I have a Dockerfile and custom nginx configuration file (in the same directory with Dockerfile) as follows:

Dockerfile:

FROM nginx

COPY nginx.conf /         


        
3条回答
  •  無奈伤痛
    2020-12-29 04:06

    An example for adding gzip config:

    docker run -v [./]gzip.conf:/etc/nginx/conf.d/gzip.conf nginx
    

    or docker-compose:

    version: '3'
    
    services:
      nginx:
        image: nginx
        volumes:
          - ./gzip.conf:/etc/nginx/conf.d/gzip.conf
          - ./html:/usr/share/nginx/html:ro
    

提交回复
热议问题