Skip to content

Instantly share code, notes, and snippets.

@seanhess
Last active June 2, 2023 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanhess/31bae53631f17563bc4ffe592c704f0a to your computer and use it in GitHub Desktop.
Save seanhess/31bae53631f17563bc4ffe592c704f0a to your computer and use it in GitHub Desktop.
Traefik super slow to pick up services on swarmmode
# Traefik Hello World example from docs: https://doc.traefik.io/traefik/getting-started/quick-start/
# This is fast! Router registers in <2 s
version: '3'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.10
# Enables the web UI and tells Traefik to listen to docker
command: --api.insecure=true --providers.docker
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
# Minimal example using swarmmode
# This is SLOW! Router registers in 10-30 seconds
version: '3'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.10
# Enables the web UI and tells Traefik to listen to docker
command:
- --api.insecure=true
- --providers.docker
- --providers.docker.swarmmode=true
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
deploy:
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
# Deploy to a docker swarm
docker stack deploy --compose-file docker-compose-slow.yml test-stack
# It can take 10-30s for the whoami router to register. Watch http://localhost:8080/dashboard/#/http/routers for changes.
# If it does register quickly, rm the stack and recreate it 2-3 times to see the problem.
docker stack rm test-stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment