Trouble running Caddy in Docker, I'd love some help :)

1. Caddy version (caddy version):

Caddy Version: 2.2.0

2. How I run Caddy:

My family’s small Weight Loss & Health business was bombed out of the water because of Covid and ever since then we’ve been struggling to shift to an online business model.

We decided to cut costs and use free and open-source software for client interactions, CRM, office suite, and a cloud for backups. (saving a lot)

The plan was to get one cloud VM and on it run various services such as Moodle, Odoo, Nextcloud and so on - each connected to a sub-domain on our website, for which I’ve settled on using Caddy Reverse Proxy and Docker. This is where the struggle begins!

a. System environment:

Docker on Debian 10 LTS

b. Command:

sudo docker-compose up -d

c. Service/unit/compose file:

version: "3.7"

services:
  caddy:
    image: caddy:<version>
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - $PWD/site:/srv
      - caddy_data:/data
      - caddy_config:/config

d. My complete Caddyfile or JSON config:

No caddyfile yet!

3. The problem I’m having:

The first problem I’m having is simply getting caddy to run on docker because although I know how to use Linux and to Code, I cannot understand the errors I run into docker - but im doing my best to learn

4. Error messages and/or full log output:

ERROR: Named volume "caddy_data:/data:rw" is used in service "caddy" but no declaration was found in the volumes section.

5. What I already tried:

Googling the error, related search terms, docker syntax - everything - 1000 times + looking for youtube tutorials or others people’s sample caddy docker-compose files (found none that would work).

I’ve even tried looking at nginx configs to try to figure it out but no luck yet, I just need more technical knowledge

6. Links to relevant resources:

Caddy Docker: Docker Hub

hi, you simply need to declare your name volumes in your compose file. The resulting file should be something like this:

version: "3.7"

services:
  caddy:
    image: caddy:<version>
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - $PWD/site:/srv
      - caddy_data:/data
      - caddy_config:/config

volumes:
  caddy_data:
  caddy_config:
2 Likes

Ah, thank you, it worked!

“It’s a simple spell but quite unbreakable”

My pleasure! I think the example should be edited to include the volumes definition, even if it is a basic Docker compose concept, it might help beginners.

I just did this today :wink:

https://github.com/docker-library/docs/pull/1817

1 Like

That’s brilliant thank you, maybe next time I could do it myself :upside_down_face: just didn’t know exactly how to contribute

1 Like

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