https://code.x3ro.net/x3ro/docker-caddy-auto-connect
925
-> Source code on my Forgejo
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.
caddy_ingress_network to each web-facing container and set
its value to the name of the networkcaddy-auto-connect (when using the
docker image
make sure to mount the docker socket: /var/run/docker.sock into the
container)docker-compose.yamlnetworks:
# 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"
docker-compose.yamlservices:
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"
| Variable | Description | Default value |
|---|---|---|
| CADDY_CONTAINER | Name of the caddy container | caddy |
| NETWORK_LABEL | Label used to get the network name | caddy_ingress_network |
Content type
Image
Digest
sha256:2f90995ae…
Size
161.3 MB
Last updated
about 1 year ago
docker pull x3rax/docker-caddy-auto-connect