Dear community,
I use traefik with docker swarm. This is working great, but going into the web UI I realize that I have duplicate config for the same service.
Let look my portainer :
the portainer@swarm is the one I use configured for DNS portainer.domain.com and mapping to backend port 9000.
But the first service looks like auto discovery from traefik, but it uses port 8000 which is wrong.
So I am wondering, is there a way to only have one HTTP service ?
FYI here is my portainer stack :
services:
traefik:
environment:
- TZ=Europe/Paris
image: "traefik:latest"
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --providers.docker
- --providers.swarm=true
# Enables the web UI and tells Traefik to listen to docker
- --api.insecure=true
- --log.level=DEBUG
- --accesslog=true
- --providers.swarm.exposedbydefault=false
ports:
- "80:80"
- "443:443"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
deploy:
restart_policy:
condition: any
placement:
constraints: [node.role == manager]
And here is portainer stack with proper config :
networks:
agent_network:
driver: overlay
attachable: true
traefik_default:
external: true
services:
agent:
image: portainer/agent:2.27.7
environment:
AGENT_CLUSTER_ADDR: tasks.agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce:lts
command: -H tcp://tasks.agent:9001 --tlsskipverify
environment:
TZ: "Europe/Paris"
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`portainer.domain.com`)"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
- "traefik.swarm.network=traefik_default"
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
- node.hostname == docker-mgmt01
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
networks:
- agent_network
- traefik_default
volumes:
portainer_data:
thank you !
