Docker Compose and Caddy Docker Proxy Setup
Chris Brocklesby
Quick example of how to setup a docker compose file with a caddy docker proxy, this is great for a fast setup and domain mapping.
First setup a Docker network for the proxy to use, this will be used for all the
containers that will be proxied to the web. docker network create caddy
.
docker-compose.yml
name: apps
services:
caddy:
image: lucaslorentz/caddy-docker-proxy:ci-alpine
ports:
- 80:80
- 443:443
environment:
- CADDY_INGRESS_NETWORKS=caddy
networks:
- caddy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- caddy_data:/data
restart: unless-stopped
whoami:
image: jwilder/whoami
restart: unless-stopped
networks:
- caddy
labels:
caddy: whoami.chrisbrocklesby.com
caddy.reverse_proxy: "{{upstreams 8000}}"
# env_file: production.env // <- Optional
volumes:
caddy_data: {}
networks:
caddy:
external: true
Run docker compose up -d
, and then go to whoami.mydomainname.com making sure
the domain points to the server via the DNS.