Caddy reload in Docker?

1. The problem I’m having:

sudo docker exec -it caddy-caddy-1 caddy reload gives me an error.

2. Error messages and/or full log output:

2026/10/09 18:57:19.125	ERROR	no config file to load

3. Caddy version:

v2.11.7 h1:yj0Y4fYZGPkSvibBJ1sTWE33xC0fxztVyXEW5iIdUT4=

4. How I installed and ran Caddy:

Docker compose at /mnt/data/Containers/Caddy. I have a Caddyfile in mnt/data/Containers/Caddy/conf. It seems to be working with my first entry in it, but I added a second entry and am getting that error when I try to reload it to apply.

a. System environment:

Ubuntu 26.04.1 LTS, x86/x64, Docker compose

b. Command:

sudo docker exec -it caddy-caddy-1 caddy reload

c. Service/unit/compose file:

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - ./conf:/etc/caddy
      - ./site:/srv
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:

d. My complete Caddy config:

immich.michellehm.com {
    reverse_proxy 127.0.0.1:2283
}

cloud.michellehm.com {
    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        X-Content-Type-Options "nosniff"
        Referrer-Policy "strict-origin-when-cross-origin"
        -Server
    }
    reverse_proxy 127.0.0.1:11000
}

5. Links to relevant resources:

Container info:

Container ID Image Names Command Created Status Ports
ba25dea2f39b caddy:latest caddy-caddy-1 “caddy run --config …” 21 hours ago Up 21 hours 0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp, 0.0.0.0:443->443/udp, [::]:443->443/udp, 2019/tcp

Okay I think I ‘fixed’ it, though I’m not really understanding why this works when the container name shows as caddy-caddy-1, but looking back at the Caddy docker install instructions I saw that to reload you should use:

sudo docker compose exec -w /etc/caddy caddy caddy reload

and not the command from the guide I was following elsewhere (can’t remember where I saw it)

sudo docker exec -it caddy-caddy-1 caddy reload

That said, now that I have this ‘working’ - neither of these reverse proxies are working :confused:, I’m getting 502 Bad Gateway on both of them in the browser.

docker exec -it caddy-caddy-1 caddy reload —config /etc/caddy/Caddyfile

— are two hyphens. The editor here turns it into a dash.

Edit: adjust the container name to your container name

I think the 502s might be coming from the upstream addresses. Inside the Caddy container, 127.0.0.1 points to Caddy itself, not your other containers. If they’re on the same Docker network, try using their service names and internal ports instead. Otherwise, use an address Caddy can actually reach.

BreezeDelegate is right about the loopback issue. Also check that the upstream app listens on all interfaces inside its container, not only localhost; it can still fail even when Caddy uses the correct Docker service name and internal port. Keep both services on the same compose network, then reload with the compose exec command that worked.