Caddy + Cloudflare repeatedly exiting in Docker

1. The problem I’m having:

Hello, I’m currently running Caddy 2.7 in a docker compose + Dockerfile combination. When I build the compose, everything installs fine. However, when I run docker compose -f caddy-compose up -d and check the logs of caddy, it will show caddy exited with code 0 and then restart the container since the container has the property restart: unless-stopped. I’m not sure why it keeps exiting. I need to use Caddy + Cloudflare because my DNS A record is needed without a cloudflare proxy and CANNOT be used with a Cloudflare proxy and I’m attempting to use a Caddy’s automatic HTTPS feature with Let’s Encrypt with an ACME DNS-01 challenge.

My goal is to automatically have a https certificate that is trusted by the browser and Cloudflare’s Origin Server CA that I manually created isn’t.

2. Error messages and/or full log output:

caddy exited with code 0

No other errors are shown other than this since it repeatedly restarts and exits.

3. Caddy version:

Caddy v2.7-builder

4. How I installed and ran Caddy:

a. System environment:

Ubuntu 22.04
Docker Engine: Built with Docker compose + Dockerfile

b. Command:

docker compose -f caddy-compose.yml build
docker compose -f caddy-compose.yml up -d
docker compose -f caddy-compose.yml logs -f

c. Service/unit/compose file:


version: "3.7"


      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    container_name: caddy
      - "80:80"
      - "443:443"
      - "443:443/udp"
      - /home/user/homelab/caddy/configs/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /home/user/homelab/caddy/configs/caddy/site:/srv
      - /home/user/homelab/caddy/configs/caddy/caddy_data:/data
      - /home/user/homelab/caddy/configs/caddy/caddy_config:/config
      - /etc/ssl:/etc/ssl
      - caddy-network

    external: true

    external: true


FROM caddy:2.7-builder AS builder

RUN xcaddy build \

FROM caddy:2.7-builder

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

d. My complete Caddy config:

Possibly relevant information: The Jellyfin service is connected through caddy with the externally available caddy-network. Domain was originally bought on GoDaddy and changed the name servers so I could use it on Cloudflare. I wasn’t sure if I needed email or not. I have another service running on port 8080, its docker file has the following information:

Complete Caddyfile

    - "8080:8080"
} {
    tls {
        dns cloudflare REDACTED
    reverse_proxy jellyfin:8096

5. Links to relevant resources:

Initial Setup was with this Caddy + Docker tutorial video:

Additional docker resources I used to create a custom build:

Try running the container interactively with docker compose run to see the logs streaming in before it dies.

If there’s really no logs, then it might be because the Caddy binary was built with the wrong architecture or something like that. That would be surprising, but it’s a theory.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.