ssl-guides 2026-12-02 ⏱ 4 min read

How to Install Free SSL on Docker

How to Install Free SSL on Docker

To install free SSL on Docker, put a Let's Encrypt certificate on the front container, usually nginx, and run Certbot in a second container that issues and renews it. Running an app in Docker usually means a web container in front of it, and that front container is where the certificate belongs. This guide gives a working compose file, the first issue command and a renewal job that runs by itself.

Free SSL on Docker: what you need first

  • A domain with an A record pointing at your server's public IP
  • Ports 80 and 443 open in the firewall or security group
  • Docker and Docker Compose installed on the host

Free SSL on Docker, option 1: nginx plus Certbot containers

The classic pattern is an nginx container acting as a reverse proxy, plus a Certbot container that requests and renews the certificate. Both share a volume that holds the certificate files:

services:
  nginx:
    image: nginx:stable
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - certdata:/etc/letsencrypt:ro
  certbot:
    image: certbot/certbot
    volumes:
      - certdata:/etc/letsencrypt
volumes:
  certdata:

Issue the first certificate

Start nginx so it serves plain HTTP, then run Certbot once. Standalone mode is simplest for a first issue, but it needs port 80 briefly, so stop the nginx container first or use webroot mode:

docker compose run --rm certbot certonly \
  --standalone -d example.com \
  --email you@example.com --agree-tos

Then point nginx at the files under /etc/letsencrypt/live/example.com/, which are fullchain.pem and privkey.pem, and reload it. The full nginx server block for this layout is in our guide on installing free SSL with Docker, nginx and Certbot, and the wider container workflow is covered in how to install Let's Encrypt with Docker.

Free SSL on Docker, option 2: let the proxy do everything

If you have not picked a proxy yet, Caddy and Traefik can request and renew certificates on their own, with no Certbot container at all. Caddy needs only a domain line in its Caddyfile; Traefik uses an ACME resolver plus labels on your app containers. The tradeoffs are laid out in our Caddy vs Traefik vs nginx comparison, and there is a dedicated Traefik SSL configuration guide if you go that route.

Keep renewal automatic

Let's Encrypt certificates last 90 days today, 64 days from 10 February 2027 and 45 days from 16 February 2028 (Let's Encrypt announcement), so renewal has to be hands-off. Add a cron job or systemd timer on the host:

docker compose run --rm certbot renew
docker compose exec nginx nginx -s reload

Run it twice a day. Since Certbot 4.0.0, a certificate is renewed only once less than a third of the lifetime is left, which is 30 days on a 90-day certificate, about 21 on a 64-day one and 15 on a 45-day one (Certbot docs), so frequent runs are cheap. More scheduling patterns, including deploy hooks, are in how to automate SSL renewal with Certbot.

Which approach fits

ApproachEffortBest for
nginx + CertbotMediumExisting nginx proxy
CaddyLowNew projects, minimal config
TraefikMediumMany containers, label-driven

Test the result

Open the site over HTTPS and confirm the padlock appears with no warnings. Then run the domain through our free SSL certificate checker to confirm the full chain is being served and the expiry date is what you expect. A missing intermediate certificate is the most common cause of a site that works in one browser but fails on another, and the checker makes that visible immediately. If a renewal later fails silently, the same check is the fastest way to spot an aging certificate before visitors do.

Add -d www.example.com to the certbot command if you also serve the www name. After the certificate exists, the nginx server block needs listen 443 ssl; plus the ssl_certificate and ssl_certificate_key paths into the shared volume.

Common pitfalls

  • Validation fails because port 80 is already bound by nginx in standalone mode. Stop the nginx container for the first issue, or use webroot mode instead.
  • The certificate works in Chrome but fails on older clients because nginx serves only the leaf certificate. Always use fullchain.pem, never cert.pem.
  • The certbot container renews but nginx keeps serving the old certificate because nobody reloaded it. The reload half of the cron job is not optional.
  • Named volumes make the certificate files awkward to back up. A bind mount to a host folder is easier to inspect and restore.

With renewal automated and the chain verified, a Docker site needs no more certificate attention than any other host. The difference is that everything lives in compose files, so rebuilding the setup on a new server reproduces the whole HTTPS configuration exactly.

Related reading: installing free SSL on a VPS, getting free SSL on DigitalOcean and what the ACME protocol is.

Frequently Asked Questions

Do I need a Certbot container for free SSL on Docker?

No. Caddy and Traefik can request and renew certificates on their own. Use the Certbot container when you already run nginx and want to keep it.

Why does nginx keep serving the old certificate after renewal?

Renewal replaces the files on disk, but nginx only reads them when it reloads. Keep the reload command in the same cron job as the renew command.

Which Certbot files should nginx use?

Use fullchain.pem and privkey.pem under /etc/letsencrypt/live/yourdomain/. Never use cert.pem, because it leaves out the intermediate certificate.

🔒 Test Your Website SSL Certificate Now
Run Free SSL Check →

✅ Post-Installation Verification & SEO Checklist

After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:

  • Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
  • Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
  • Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
  • Confirm both root and www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant