I want to use caddy.json with docker-compose how can i?

1. Caddy version (caddy version):

v2.5.0

2. How I run Caddy:

i am running the caddy with docker-compose

a. System environment:

b. Command:

npm run "dev:docker:minimal": "docker-compose -f \"docker-compose.dev.yml\" up -d --build arango minio mongo redis redis-insights caddy    ",
Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

Paste config here, replacing this text.
Use `caddy fmt` to make it readable.
DO NOT REDACT anything except credentials.
LEAVE DOMAIN NAMES INTACT.
Make sure the backticks stay on their own lines.

3. The problem I’m having:

i tried to use caddy.json in docker-compose but it is not redirecting my site to a proper port

4. Error messages and/or full log output:

5. What I already tried:

caddy:
image: caddy/caddy:2.5.0-alpine
container_name: caddy-service
restart: unless-stopped
ports:
- “80:80”
- “443:443”
volumes:
- $PWD/caddy.json:/etc/caddy/caddy.json

  - $PWD/site:/srv
  - caddy_data:/data
  - caddy_config:/config

6. Links to relevant resources:

If you want to use JSON instead of a Caddyfile, you’ll need to override the command that the container runs with. See the docs on Docker Hub

which file i have to override…?

  • $PWD/caddy.json:/etc/caddy/Caddyfile

Your volumes were fine, you need to override the command the container starts up with.

So, command: caddy run --config /etc/caddy/caddy.json

1 Like

thank you man! issue solved

1 Like

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