HUB
Sign inSign up

emulator/docker-nginx-lego

By emulator

•Updated 8 days ago

from upper stream docker-nginx-certbot just use lego instead

Image
Networking
Developer tools
Web servers
0

10K+

emulator/docker-nginx-lego repository overview

⁠docker-nginx-lego

Nginx with automatic SSL/TLS certificate management via Let's Encrypt⁠ and lego⁠. No Python. No certbot. Just a static Go binary.

Fork of JonasAlfredsson/docker-nginx-certbot⁠ with certbot replaced by lego — endorsed by the upstream author.

⚠️ Breaking change from lego5.6.0-nginx1.31.8: the image no longer runs as root. Every image now runs as the unprivileged user 101:101. latest, latest-alpine and latest-ubuntu move to it on release; lego5.4.1-nginx1.31.8 and older still run as root. An existing setup needs a one-time migration, most often: docker run --rm --user 0 -v <volume-or-dir>:/etc/letsencrypt emulator/docker-nginx-lego chown -R 101:101 /etc/letsencrypt. Read Upgrading to the Non-Root Image⁠ before you pull.

⁠Quick start

docker run -d -p 80:80 -p 443:443 \
  --cap-drop ALL --security-opt no-new-privileges \
  -e [email protected] \
  -v nginx_secrets:/etc/letsencrypt \
  -v $(pwd)/user_conf.d:/etc/nginx/user_conf.d:ro \
  emulator/docker-nginx-lego:lego5.6.0-nginx1.31.8

Place your nginx server configs in user_conf.d/. The container handles cert issuance and renewal automatically.

Nginx's workers run as the same user as lego, so code running in a worker could read your DNS credentials. Use least-privilege DNS tokens and keep the two flags above; see What it means for security⁠.

⁠Tags

Tags encode the exact component versions:

lego<X.Y.Z>-nginx<X.Y.Z>          # Debian
lego<X.Y.Z>-nginx<X.Y.Z>-alpine   # Alpine
lego<X.Y.Z>-nginx<X.Y.Z>-ubuntu   # Ubuntu 24.04

Use a specific tag in production. See the full tag list⁠.

⁠Certificate naming

The cert name in your nginx config drives how the certificate is obtained:

# HTTP-01 webroot (default)
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

# DNS-01 via Cloudflare
ssl_certificate_key /etc/letsencrypt/live/example.com.dns-cloudflare/privkey.pem;

# DNS-01 via Route53 (env vars, no .ini file needed)
ssl_certificate_key /etc/letsencrypt/live/example.com.dns-route53/privkey.pem;

150+ DNS providers supported. See the provider list⁠.

⁠Key environment variables

VariableDefaultPurpose
CERTBOT_EMAILrequiredLet's Encrypt account email
STAGING0Use LE staging servers (set to 1 for testing)
LEGO_DEFAULT_PROVIDER—Default DNS provider for all certs
CERTBOT_DNS_CREDENTIALS_DIR/etc/letsencryptDirectory for .ini credential files
RENEWAL_INTERVAL8dTime between renewal checks
USE_ECDSA1ECDSA certs (set to 0 for RSA only)
NGINX_LEGO_CERT_GROUP—Group (name or gid) given read access to the certificates, for another container (how⁠)

⁠Volumes

PathPurpose
/etc/letsencryptCertificates, lego accounts, DH params (persist this; writable by uid 101)
/etc/nginx/user_conf.dYour nginx server configs (mount read-only)

⁠Architectures

ArchitectureDebianAlpineUbuntu
linux/amd64✓✓✓
linux/386✓——
linux/arm64✓✓✓
linux/arm/v7✓——

Tag summary

Content type

Image

Digest

sha256:2f37c0b90…

Size

76.2 MB

Last updated

8 days ago

docker pull emulator/docker-nginx-lego