Traefik with docker swarm as loadbalancer -> Bad Gateway

Hi @Stargate, I tried to reproduce you case and caught 2 errors in the docker service of Traefik:


First:

traefik_traefik.1.wdn1uhibsxbi@docker-desktop    | time="2019-10-26T09:41:52Z" level=warning msg="Could not find network named 'traefik-proxy' for container 'traefik_traefik.1'! Maybe you're missing the project's prefix in the label? Defaulting to first available network." container=traefik-traefik-wdn1uhibsxbio80neggxkglg6 serviceName=traefik-traefik providerName=docker

=> You might not have this error: it is related to the space between the last line of the command: > yaml node and networks:. When checking the Docker API, I saw that the Traefik container was not attached to the network traedfik-proxy. By removing the empty line and redeploying, this error went away


Second:

      --providers.docker.exposedbydefault=false

This flag means that Traefik takes in account only the containers which have the label traefik.enable set to true. But Traefik itself do not have this label in your snippet, so it ignores itself and the configuration is never created.

=> Add the label - traefik.enable=true to Traefik itself.


Third:

When using Swarm, Traefik cannot determines the exposed port automatically as how it does with Docker Engine. It is mandatory to specify this port as if there were multiple ports. I don't know why (yet) but you must create a "dummy" service with a port, which won't be used but is still required.

=> Add the label traefik.http.services.api-dummy.loadbalancer.server.port=99999 to the Traefik service.

With these 3 elements you should be ready to go :slight_smile: