No description
Find a file
2025-07-24 18:13:56 +02:00
src 📦 NEW: Make caddy container name and network label configurable 2025-07-23 17:45:37 +02:00
.gitignore 📦 NEW: Add first version of caddy-auto-connect 2025-07-23 16:28:40 +02:00
deno.json 📦 NEW: Add first version of caddy-auto-connect 2025-07-23 16:28:40 +02:00
deno.lock 📦 NEW: Add first version of caddy-auto-connect 2025-07-23 16:28:40 +02:00
Dockerfile 🐛 FIX: Change casing of AS keyword in FROM directive 2025-07-23 19:19:41 +02:00
justfile 👌 IMPROVE: Change docker image name 2025-07-23 19:18:42 +02:00
LICENSE 👌 IMPROVE: Add license 2025-07-23 18:09:17 +02:00
README.md 📖 DOC: Fix docker hub url 2025-07-24 18:13:56 +02:00

Docker Caddy Auto-Connect

-> Image on Docker Hub

This is a companion to Caddy-Docker-Proxy that auto-connects the Caddy container to the ingress network of your web-facing containers.

This approach ensures that your app networks are segregated so apps can't reach each other but can still all be connect to the same Caddy instance.

Usage

  • Define a name for your Caddy container
  • Add a network for each web-facing container that will be shared with caddy
  • Add all web-facing containers to their caddy-shared networks respectively
  • Add the label caddy_ingress_network to each web-facing container and set its value to the name of the network
  • Start caddy-auto-connect (when using the docker image make sure to mount the docker socket: /var/run/docker.sock into the container)

Docker Compose Example

App docker-compose.yaml

networks:
  # Create a network for the web-facing app (this network will be prefixed with
  # the docker-compose project name)
  caddy:

services:
  caddy:
    image: some/app
    networks:
      # Add the network to the web-facing container (use the name defined in
      # the `docker-compose.yaml`)
      - caddy
    labels:
      # Set the ingress network to the name of the network. If you didn't
      # define a custom network name, prefix the name with
      # `${COMPOSE_PROJECT_NAME}_`
      caddy_ingress_network: "${COMPOSE_PROJECT_NAME}_caddy"

Caddy + Auto-Connect docker-compose.yaml

services:
  caddy:
    container_name: caddy # Required for caddy-auto-connect
    image: lucaslorentz/caddy-docker-proxy:ci-alpine
    # ...

  auto-connect:
    image: x2rax/docker-caddy-auto-connect
    depends_on:
      - caddy
    environment:
      CADDY_CONTAINER: "caddy"
      NETWORK_LABEL: "caddy_ingress_network"
    volumes:
      - "${DOCKER_SOCK:-/var/run/docker.sock}:/var/run/docker.sock:ro"

Environment Variables

Variable Description Default value
CADDY_CONTAINER Name of the caddy container caddy
NETWORK_LABEL Label used to get the network name caddy_ingress_network