Quickstart: Setup Caddy-Docker-Proxy with Docker Compose
masterTo use Caddy-Docker-Proxy, you need to create a dedicated Docker network (ideally with IPv6 support to ensure correct client IP visibility) and run the Caddy container with access to the Docker socket.
Create the network:
docker network create caddy --ipv6Configure the Caddy service in
compose.yaml:- Use the
lucaslorentz/caddy-docker-proxy:ci-alpineimage. - Map ports 80, 443 (TCP), and 443 (UDP).
- Set
CADDY_INGRESS_NETWORKS=caddyto tell the plugin which network to monitor for upstreams. - Mount
/var/run/docker.sockto allow the plugin to scan Docker metadata. - Mount a volume for Caddy data (e.g.,
caddy_data:/data) to persist certificates.
- Use the
Configure your application service (e.g.,
whoami) to be proxied:- Connect it to the
caddynetwork. - Add labels starting with
caddyto define the domain and proxy behavior.
- Connect it to the
### caddy/compose.yaml
services:
caddy:
image: lucaslorentz/caddy-docker-proxy:ci-alpine
ports:
- 80:80
- 443:443/tcp
- 443:443/udp
environment:
- CADDY_INGRESS_NETWORKS=caddy
networks:
- caddy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- caddy_data:/data
restart: unless-stopped
networks:
caddy:
external: true
volumes:
caddy_data: {}
### whoami/compose.yaml
services:
whoami:
image: traefik/whoami
networks:
- caddy
labels:
caddy: whoami.example.com
caddy.reverse_proxy: "{{upstreams 80}}"
networks:
caddy:
external: true