Hi,
in Docker Swarm, I'd like to launch Traefik as a service, with replicas=1, but not running in swarmMode, so that I could then route all the standalone containers (non-Swarm) running on the cluster nodes.
I've tried the following setup but it isn't working:
docker service create --constraint node.id==XYZ --hostname traefik --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --network shared --name traefik traefik:2.3.5 --entrypoints.mqtt.address=:1883 --providers.docker=true --providers.docker.exposedbydefault=false
and then, on node XYZ, I'm running
docker-compose up
, where docker-compose.yml (snippet) is
mosquitto:
image: eclipse-mosquitto:1.6.12
networks:
- shared
labels:
- "traefik.enable=true"
- "traefik.tcp.routers.mytcprouter.rule=HostSNI(`*`)"
- "traefik.tcp.routers.mytcprouter.entrypoints=mqtt"
- "traefik.tcp.routers.mytcprouter.service=mosquitto"
- "traefik.tcp.services.mosquitto.loadbalancer.server.port=1883"
when the mosquitto container is up, I can ping "traefik" from inside, however, the MQTT routing is not working, cause when I try mosquitto_pub -h shared -t test -m "test msg"
, the command will hang and timeout, and on the "traefik" side, I'll see the error:
time="2021-02-24T14:52:38Z" level=error msg="Error while connection to backend: dial tcp 172.24.0.2:1883: connect: connection timed out"
any ideas? Is this possible at all? It works well if "traefik" is a container and not a service.