Caddy Docker with DuckDNS

1. Caddy version:


name: caddy
    container_name: caddy
      DUCKDNS_TOKEN: token
      LOG_FILE: /data/access.log
    image: caddy
      default: null
    - mode: ingress
      target: 80
      published: "91480"
      protocol: tcp
    - mode: ingress
      target: 443
      published: "99443"
      protocol: tcp
    restart: always
    - type: bind
      source:  /mnt/path/to/caddy/Caddyfile
      target: /etc/caddy/Caddyfile
      read_only: true
        create_host_path: true
    - type: bind
      source:  /mnt/path/to/caddy/caddy-config
      target: /config
        create_host_path: true
    - type: bind
      source: /mnt/path/to/caddy/caddy-data
      target: /data
        create_host_path: true
    name: caddy_default

2. How I installed, and run Caddy:

Docker compose via Portainer

a. System environment:

Portainer running on TrueNAS Scale using the latest docker for Debian.

b. Command:


d. My complete Caddy config:

{$DOMAIN}:443 {
  log {
    level INFO
    output file {$LOG_FILE} {
      roll_size 10MB
      roll_keep 10

  # Use the ACME DNS-01 challenge to get a cert for the configured domain.
  tls {
    dns duckdns {$DUCKDNS_TOKEN}

  # This setting may have compatibility issues with some browsers
  # (e.g., attachment downloading on Firefox). Try disabling this
  # if you encounter issues.
  encode gzip

  # Notifications redirected to the WebSocket server
  reverse_proxy /notifications/hub vaultwarden:3012

  # Proxy everything else to Rocket
  reverse_proxy vaultwarden:80

3. The problem I’m having:

Can’t seem to use DuckDNS, and found no guide on how to use DuckDNS with Docker Caddy.

4. Error messages and/or full log output:

INF ts=1674810469.9022279 msg=using provided configuration config_file=/etc/caddy/Caddyfile config_adapter=caddyfile
Error: adapting config using caddyfile: parsing caddyfile tokens for 'tls': /etc/caddy/Caddyfile:12 - Error during parsing: getting module named 'dns.providers.duckdns': module not registered: dns.providers.duckdns

5. What I already tried:

Tried looking on this forum and other sources for a guide on how to do this.

6. Links to relevant resources:

See this article:

You need to build Caddy with the DNS plugin added. See the docs on Docker, the “Adding custom Caddy modules” section in particular.


thanks for the reply, but both links refer to xcaddy, do I need to install that on the host machine?

No, xcaddy is run within the container when it’s built from the Dockerfile.

OK, seeing as I never built a docker from a repo before only from my images or just downloaded ones from the hub, I have one question:

FROM caddy:<version>-builder AS builder

RUN xcaddy build \
    --with \

FROM caddy:<version>

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Where exactly do I put that example?

You add that to a file called Dockerfile. Then you build a docker image using that Dockerfile as the instructions.

I suggest you read some guides to learn about Docker. I can’t reasonably spend time here to teach the basics of Docker. The information is out there on the internet.

OK, I did not expect you to, but I did want to point out the assumptions in that guide you sent me. It assumes you know 90% of the process, and skips information like this.

Using Caddy with plugins is inherently a more advanced thing to do.

Documentation can’t always assume you know nothing, because then every piece of documentation would need to be very long and repetitive, and a waste of time for the doc writers and readers who already understand. It’s best to only give the relevant information, and the user should look elsewhere to learn the basics if they don’t understand.

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