Nginx [SOLVED]: How do I use dynamically generated Nginx config files with Docker?

Nginx [SOLVED]: How do I use dynamically generated Nginx config files with Docker?

Home Forums Nginx Nginx [SOLVED]: How do I use dynamically generated Nginx config files with Docker?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36709

    Anonymous

    QuestionQuestion

    I am developing an application using Nginx and ExpressJS (NodeJS) and I am using Docker (with docker-compose)

    I had not written the application keeping Docker in mind.

    My application dynamically creates Nginx configurations. Originally, these Nginx configurations were placed in a standard directory within my application. I had configured Nginx to read all *.conf files from this directory and everything worked great.

    Now that I am using Docker, I am using two different containers: One for Nginx and one for my application.

    Question: How do I move the generated config files from one container to another?

    Is there a better way to achieve this?

    #36710

    Anonymous

    Accepted AnswerAnswer

    You could run both your container mounting the same volume.
    See “Docker Volumes“.

    The first container would generate the configuration files in that volume.
    The second container (NGiNX) would read them.

    See as an example Volume configuration reference:

    version: "3"
    
    services:
      db:
        image: db
        volumes:
          - data-volume:/var/lib/db
      backup:
        image: backup-service
        volumes:
          - data-volume:/var/lib/backup/data
    
    volumes:
      data-volume:
    

    Here the same volume is mounted twice.

    Source: https://stackoverflow.com/questions/47970977/how-do-i-use-dynamically-generated-nginx-config-files-with-docker
    Author: VonC
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.