Caddy Plugin / Binary with Docker

1. The problem I’m having:

Hello. I was wondering how to get a Caddy plugin (specifically cloudflare) when deploying Caddyv2 with docker? Specifically because I’m using cloudflare origin ca certificates right now on my website but any browser says its not a trust-worthy certificate since it’s self-certified. However, I realized if I use let’s encrypt with dns-acme, it should provide a trustworthy certificate. I’m not sure it’s listed on the docs / I’m not understanding the docs properly. Basically, my question is is it possible to use a caddy+cloudflare with docker compose? If so, can someone explain to me how to achieve this with docker compose?

2. Error messages and/or full log output:


3. Caddy version:

Caddy v2.6.4 through docker compose

4. How I installed and ran Caddy:

a. System environment:

OS Ubuntu 22.04
Docker Compose

b. Command:

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

c. Service/unit/compose file:

version: "3.7"

    image: caddy:latest
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - "443:443/udp"
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - $PWD/site:/srv
      - caddy_data:/data
      - caddy_config:/config

    external: true

d. My complete Caddy config:


5. Links to relevant resources:

The docs on explain how to write a Dockerfile which builds Caddy with the plugins you need. Replace image: in your docker-compose.yml with build: pointing to your Dockerfile.

I don’t have a docker file however. I have a docker-compose.yml. Is there any way to do it with a compose? Sorry, is there a way you could througly explain how to do the docker file + docker compose setup? I’m decently new to docker so I’m not sure I understand what you’re saying.

It’s not one or the other, you need both files. The docker-compose.yml file is a definition of all the services you want to run (it’s a replacement for running a bunch of docker run commands in sequence), and a Dockerfile is instructions to build a single image. They serve separate purposes.

I suggest you do some more reading about how Docker works, look at Docker official documentation, etc.

1 Like

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