The official Certbot documentation (https://certbot.eff.org/instructions) does not provide configuration examples for Docker and Docker Compose. This guide fills that gap.
-
Copy the
certbotservice fromdocker-compose.ymlfile -
Add volumes to your nginx service using
docker-compose.ymlexample -
Change nginx conf, add location into your server section for port 80 and 443, which shares the location for ACME challenges
location /.well-known/acme-challenge/ { root /var/www/certbot; }into 80 and 403 ports -
run
certbotcontainer and inside this conainer run command:certbot certonly -d yourdomain.com --webroot -w /var/www/certbot -
Add in 443 port server section
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
into nginx.conf
docker-compose
| Component | Version |
|---|---|
docker-compose |
>3 |
docker |
Compatible with docker-compose |