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:
1
version: '3.3'
2
volumes:
3
certificates:
4
​
5
services:
6
nginx-le:
7
container_name: nginx-le
8
image: noojee/nginx-le:latest
9
restart: on-failure
10
ports:
11
- "80:80"
12
- "443:443"
13
network_mode: "host"
14
environment:
15
HOSTNAME: www
16
DOMAIN: example.com.au
17
TLD: com.au
18
DOMAIN_WILD_CARD: "false"
19
PRODUCTION: "true"
20
EMAIL_ADDRESS: [email protected]
21
AUTO_ACQUIRE: "true"
22
DEBUG: "true"
23
AUTH_PROVIDER: cloudflare
24
AUTH_PROVIDER_TOKEN: XXXXXXX
25
AUTH_PROVIDER_EMAIL_ADDRESS: [email protected]
26
SMTP_SERVER: smtp.someserver.com
27
SMTP_SERVER_PORT: 25
28
volumes:
29
- certificates:/etc/letsencrypt
30
- /opt/nginx/include:/etc/nginx/include
31
logging:
32
driver: "journald"
Copied!
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 modified 2mo ago