How to use plugins with docker?

Hey,

Is it possible to use caddy plugins when I use the docker container?

If yes, how?

See the docs on Docker Hub, there’s a section that explains how to write a Dockerfile to build with plugins. See “Adding custom Caddy modules”

This is my setup.

Dockerfile:

FROM caddy:2.7.5-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/hairyhenderson/caddy-teapot-module \
    --with github.com/caddy-dns/cloudflare

FROM caddy:2.7.5

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

Then docker build . will make the plugged image for you.

If you run this in a compose scenario, you just point your Caddy section to the local build instead of a public image:

  caddy:
    build:
      context: ./caddy
      dockerfile: Dockerfile
    restart: always

In this case the Dockerfile is located like:
caddy/Dockerfile
docker-compose.yml

1 Like

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