Caddyfile in the docker container is at 3 different places, which one should bind my named volume to?

1. Caddy version: 2.3.0-alpine

2. How I run Caddy: By docker-compose

version: ‘3.8’

services:
caddy:
image: caddy:2.3.0-alpine
container_name: caddy
ports:
- 80:80
- 443:443
volumes:
- caddy:/etc/caddy/
- caddy:/config
- caddy:/data
networks:
- main
restart: unless-stopped

networks:
main:
external: true

volumes:
caddy:

3. The problem I’m having:

Why does Caddyfile and autosave.json exists in 3 different directories inside the caddy docker container?
I can find Caddyfile at: “etc/caddy/Caddyfile”, “/config” and “/data”. So which one should I bind my named volume to?

Please fill out the topic template – what does your docker-compose.yml look like?

Hi there. I just filled up what I thought was nessecery for the scope of the problem.
Anways I just pasted my whole compose file in the question.

But my question is just why there is three Caddyfiles at three different locations inside the running container

This is incorrect, you’re mounting the same volume on the host to all three of these locations in the container. They should all be different volumes. The example on Docker shows how it should look.

I tried your suggestion and the result checks out. It was because I was mounting the same named-volume to these different paths

The solution:

version: ‘3.8’

services:
caddy:
image: caddy:2.3.0-alpine
container_name: caddy
ports:
- 80:80
- 443:443
volumes:
- caddyfile:/etc/caddy
- caddy_data:/data
- caddy_config:/config
networks:
- main
restart: unless-stopped

networks:
main:
external: true

volumes:
caddyfile:
caddy_data:
caddy_config:

1 Like

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