1. The problem I’m having:
Hello, I try to build caddy with the dns provider module using the :builder image with docker compose. My goal is to be able to have automatic https using the DNS challenge. However once built and started the container appears to keep restarting. I get this error “caddy_build exited with code 0” I ran docker compose build and then docker compose up. I seem to be unable to get more details regarding what is going wrong. I think this is because the container keeps restarting. Below is what is output to the terminal from the compose build step and then the compose up step. I’m not sure how to figure out what could be wrong. As a side note, I can confirm I can successfully get Caddy 2.9-alpine docker image running on this environment when I don’t try building with plugins. Seems the trouble lies with building with plugins.
2. Error messages and/or full log output:
docker compose build
[+] Building 243.3s (8/8) FINISHED docker:default
=> [caddy internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 223B 0.0s
=> [caddy internal] load metadata for docker.io/library/caddy:2.9-builder-alpine 0.2s
=> [caddy internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [caddy builder 1/2] FROM docker.io/library/caddy:2.9-builder-alpine@sha256:192533a0715e00011c17b9622e9eb343ef751658efe0a8b5e8444805475a5ce9 0.0s
=> [caddy builder 2/2] RUN xcaddy build --with github.com/caddy-dns/porkbun 242.1s
=> [caddy stage-1 2/2] COPY --from=builder /usr/bin/caddy /usr/bin/caddy 0.1s
=> [caddy] exporting to image 0.2s
=> => exporting layers 0.2s
=> => writing image sha256:78f88b88b6f78633f2fda2f26d3aa19d27775d46d156df0f0cdc232733eb5347 0.0s
=> => naming to docker.io/library/caddy-build-demo-pk-caddy 0.0s
=> [caddy] resolving provenance for metadata file
docker compose up
[+] Running 3/3
✔ Volume "caddy-build-demo-pk_caddy_build_config" Created 0.0s
✔ Volume "caddy-build-demo-pk_caddy_build_data" Created 0.0s
✔ Container caddy_build Created 0.1s
Attaching to caddy_build
caddy_build exited with code 0
caddy_build exited with code 0
caddy_build exited with code 0
caddy_build exited with code 0
caddy_build exited with code 0
caddy_build exited with code 0
3. Caddy version:
I’m unable to get the output of the verison from the docker compose exec caddy caddy version command, it outputs that the container is restarting, wait until the container is running.
4. How I installed and ran Caddy:
a. System environment:
Digital Ocean Droplet running Docker on Ubuntu 22.04
Docker version 27.3.1, build ce12230
Docker Compose version v2.30.3
buildx v0.17.1 257815a
b. Command:
docker compose build
docker compose up
c. Service/unit/compose file:
My compose.yml
services:
caddy:
container_name: caddy_build
build: .
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./site:/srv
- caddy_build_data:/data
- caddy_build_config:/config
volumes:
caddy_build_data:
caddy_build_config:
My Dockerfile
FROM caddy:2.9-builder-alpine AS builder
RUN xcaddy build \
--with github.com/caddy-dns/porkbun
FROM caddy:2.9-builder-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
My .env file
PORKBUN_API_KEY="redacted"
PORKBUN_API_SECRET_KEY="redacted"
My site directory contains an index.html containing
<h1>Hello World</h1>
d. My complete Caddy config:
doporkbun.superherodonut.com {
tls {
dns porkbun {
api_key {env.PORKBUN_API_KEY}
api_secret_key {env.PORKBUN_API_SECRET_KEY}
}
}
root * /srv
file_server
}
5. Links to relevant resources:
Similar error this user experienced not sure if they ever were able to resolve.