A Docker solution for managing Let's Encrypt SSL/TLS certificates using the Lego client.
1.3K
A Docker solution for managing Let's Encryptβ SSL/TLS certificates using the Legoβ client. Designed to run as a background service with automatic renewal and minimal configuration.
docker compose pluginDownload the docker-compose.ymlβ file and place it in a convenient location on your disk.
Edit the file to set the required environment variables:
LEGO_ADMIN_EMAIL β Your email address (used for Let's Encrypt account registration and expiry notifications).LEGO_DNS_PROVIDER β Your DNS provider (e.g., cloudflare, route53, gandi).You must also provide credentials for your chosen DNS provider. These are passed as environment variables β refer to the Lego DNS provider documentationβ for details (e.g., CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY).
docker compose up -d
docker compose exec app certctl new -d="example.com" -d="*.example.com"
docker compose down
docker compose down -v
This deletes the Docker volume containing certificates and keys β use with caution.
| Variable | Description |
|---|---|
LEGO_ADMIN_EMAIL | Email for Let's Encrypt registration (required). |
LEGO_DNS_PROVIDER | DNS provider name (required). |
LEGO_ACCEPT_TOS | Automatically accept Let's Encrypt terms of service (required) β set to true. |
DNS provider credentials are passed as separate environment variables according to Legoβs requirements (e.g., CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY).
Mount the certificate volume to your reverse proxy container. Example snippet for Nginx:
volumes:
lego-certs:
name: "certs_global_storage" # or set your...
external: true
services:
nginx:
image: nginx:alpine
volumes:
- lego-certs:/etc/nginx/certs:ro
Run the container in foreground mode to see live logs:
docker compose up
Or check logs of the running container:
docker compose logs -f
A Makefile is included for developers. It simplifies building and managing the container.
make init β Prepare the environment.make clean β Remove unused Docker resources.make pull β Pull base images.make build β Build the Lego Docker image.make push β Push the built image to a registry.make up β Start the service.make down β Stop the service.make down-with-volumes β Stop the service and delete volumes.make restart β Restart the service.This project is licensed under MIT licenseβ .
Maintainer: Eugene Frostβ Repository: GitHubβ Registry: Docker HUBβ
β₯οΈ Issues and pull requests are welcome!
Content type
Image
Digest
sha256:fa8de9519β¦
Size
45 MB
Last updated
5 months ago
docker pull tuzelko/lego