Skip to content
Runbook

Install Caddy on Docker

Modern web server with automatic HTTPS, usable as a reverse proxy and file server.

Toolweb-serverreverse-proxyhttpstlshttp

Installation

Container (official image) · Docker
docker run -d --name caddy -p 80:80 -p 443:443 -v caddydata:/data caddy

The named volume caddydata persists issued TLS certificates across restarts.

Verify the installation

Verify
docker exec caddy caddy version

Important files

TypePathDescription
config/etc/caddy/CaddyfileConfiguration inside the container; mount your own Caddyfile here.
data/dataWhere Caddy stores TLS certificates and state; mount on a volume to persist them.

Default ports

80443

Command-line tools

  • caddyThe server binary inside the container; reload with docker exec caddy caddy reload --config /etc/caddy/Caddyfile.

Uninstall

Remove the container
docker rm -f caddy

Does NOT delete the caddydata volume.

Also remove the data
docker volume rm caddydata

Removes the stored certificates and state.

Good to know

  • Persist /data on a volume: otherwise Caddy re-issues certificates on every recreation and may hit rate limits.
  • Provide your config by mounting it: -v $(pwd)/Caddyfile:/etc/caddy/Caddyfile, then docker exec caddy caddy reload --config /etc/caddy/Caddyfile.
  • For automatic HTTPS on a public domain, publish ports 80 and 443 and point the domain's DNS at the host.

Running Caddy with Docker

The official caddy image runs the server out of the box. The command above publishes ports 80 and 443 and persists certificates in the named volume caddydata mounted at /data. Verify with docker exec caddy caddy version.

Providing a Caddyfile

Mount your configuration over the default path: -v $(pwd)/Caddyfile:/etc/caddy/Caddyfile. After editing it, apply changes with docker exec caddy caddy reload --config /etc/caddy/Caddyfile — no container restart required.

Persisting certificates

Caddy stores issued TLS certificates and state under /data. Always mount it on a volume (caddydata above); otherwise every container recreation re-issues certificates and can hit the certificate authority's rate limits.