docker-compose

Start with docker-compose

May users deploy their docker containers using docker-compose. In these circumstances using the Nginx-LE cli tools may not be appropriate.

This is the case for most production systems, in which case you will just use the standard docker management tools.

Whilst it can be useful to run nginx-le config, it is not required and for most users won't be needed.

If you want to use any of the nginx-le commands you MUST first run:

  • docker-compose up at least once

  • nginx-le config.

Note: If you do use nginx-le config then if you change your dock-compose configuration, docker-compose will recreate the container. When this occurs you MUST re-run nginx-le config and select the new container.

To start Nginx-LE with docker-compose you must provide a number of configuration settings:

The following is a sample configuration:

version: '3.3'
volumes:
  certificates:

services:   
  nginx-le:
    container_name: nginx-le
    image: noojee/nginx-le:latest
    restart: on-failure
    ports:
      - "80:80"
      - "443:443"
    network_mode: "host"
    environment: 
      HOSTNAME: www
      DOMAIN: example.com.au
      TLD: com.au
      DOMAIN_WILD_CARD: "false"
      PRODUCTION: "true"
      EMAIL_ADDRESS: support@example.com
      AUTO_ACQUIRE: "true"
      DEBUG: "true"
      AUTH_PROVIDER: cloudflare
      AUTH_PROVIDER_TOKEN: XXXXXXX
      AUTH_PROVIDER_EMAIL_ADDRESS: XXX@XXXXX
      SMTP_SERVER: smtp.someserver.com
      SMTP_SERVER_PORT: 25
    volumes:
      - certificates:/etc/letsencrypt
      - /opt/nginx/include:/etc/nginx/include
    logging:
      driver: "journald"

The environment variables for the Auth Provider will change based on which Auth Provider you have selected.

Volumes

The certificates volume is used to store the certbot certificates between restarts. The /opt/nginx/include host path is where you place the nginx .location and .upstream includes.

Acquire a certificate

If you set the environment variable AUTO_ACQUIRE=true then Nginx-LE will automatically acquire and renew certificates as required.

If you don't pass the AUTO_ACQUIRE environment variable or set it to false than you must manually acquire a certificate (using nginx-le acquire).

We strongly recommend using AUTO_ACQUIRE and don't know of any valid reason why you would not.

Last updated