No description
| src | ||
| .gitignore | ||
| deno.json | ||
| deno.lock | ||
| Dockerfile | ||
| justfile | ||
| LICENSE | ||
| README.md | ||
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_networkto 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.sockinto 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 |