Please see the official Caddy Docker Image for deployment instructions.
Builds are available at the following Docker repositories:
- GitHub Container Registry: ghcr.io/runbgp/caddy-cloudflare-dns
- Docker Hub: docker.io/runbgp/caddy-cloudflare-dns
- Add your
CLOUDFLARE_EMAIL
andCLOUDFLARE_API_TOKEN
as environment variables to yourdocker-compose.yml
ordocker-run
command.
services:
caddy:
image: ghcr.io/runbgp/caddy-cloudflare-dns:latest
restart: unless-stopped
container_name: caddy
ports:
- "80:80"
- "443:443"
networks:
- caddy
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./data:/data
- ./config:/config
environment:
- CLOUDFLARE_EMAIL=$CLOUDFLARE_EMAIL
- CLOUDFLARE_API_TOKEN=$CLOUDFLARE_API_TOKEN
- ACME_AGREE=true
networks:
caddy:
name: caddy
docker run -it --name caddy \
-p 80:80 \
-p 443:443 \
-v caddy_data:/data \
-v caddy_config:/config \
-v $PWD/Caddyfile:/etc/caddy/Caddyfile \
-e CLOUDFLARE_EMAIL=$CLOUDFLARE_EMAIL \
-e CLOUDFLARE_API_TOKEN=$CLOUDFLARE_API_TOKEN \
-e ACME_AGREE=true \
ghcr.io/runbgp/caddy-cloudflare-dns:latest
You can obtain your Cloudflare API token via the Cloudflare Portal. To create an API token with minimal scope, the following steps are needed:
- Log into the Cloudflare dashboard, navigate to account settings and create an API token.
- Grant the following permissions:
- Zone / Zone / Read
- Zone / DNS / Edit
- Add the following to your Caddyfile's tls directive.
tls {$CLOUDFLARE_EMAIL} {
dns cloudflare {$CLOUDFLARE_API_TOKEN}
}
To select a specific version of caddy
, set your Docker image tag to the Caddy version you'd like to use, e.g. runbgp/caddy-cloudflare-dns:2.8.0