Introduction
A dynamic docker→redis→traefik discovery agent.
Solves the problem of running a non-Swarm/Kubernetes multi-host cluster with a single public-facing traefik instance.
+---------------------+ +---------------------+
| | | |
+---------+ :443 | +---------+ | :8088 | +------------+ |
| WAN |--------------->| traefik |<-------------------->| svc-nginx | |
+---------+ | +---------+ | | +------------+ |
| | | | |
| +---------+ | | +-------------+ |
| | redis |<-------------------->| traefik-kop | |
| +---------+ | | +-------------+ |
| docker1 | | docker2 |
+---------------------+ +---------------------+
traefik-kop solves this problem by using the same traefik docker-provider logic. It reads the container labels from the local docker node and publishes them to a given redis instance. Simply configure your traefik node with a redis provider and point it to the same instance, as in the diagram above.
Instructions
Pre-requisites
Traefik Configuration
Add redis to traefik’s docker-compose file:
services:
...
redis:
image: docker.io/library/redis:alpine
command: --save 60 1 --loglevel warning
restart: unless-stopped
container_name: traefik-redis
networks:
- proxy
ports:
- 6379:6379
volumes:
- ~/containers/traefik/data/redis/:/data
...Apply changes to the stack
docker compose up -dAdd redis to traefik providers
...
providers:
...
redis:
endpoints:
- "traefik-redis:6379"
...Docker Compose
services:
traefik-kop:
image: ghcr.io/jittering/traefik-kop:0.14
container_name: traefik-kop
restart: unless-stopped
networks:
- proxy
- socket
environment:
- BIND_IP=x.x.x.x # IP of system running this container
- REDIS_ADDR=x.x.x.x:6379 # IP of system running main traefik instance
- DOCKER_HOST=tcp://socket-proxy:2375
networks:
proxy:
external: true
socket:
external: true