Traefik not detecting services in Docker swarm

I've managed to deploy a traefik with swarm, see this post in the forum.

However, I'm facing an issue: The services deployed in swarm are not correctly being seen by traefik.

This is the services I'm deploying:

version: "3.5"

      name: web
    name: internal
    driver: overlay

    image: mysql:5.7
      - internal
      - traefik.enable=false

    image: adminer:4.6.3-standalone
        - traefik.http.routers.adminer.rule=Host(``)
        - traefik.http.routers.adminer.tls=true
        - traefik.http.routers.adminer.tls.certresolver=lets-encrypt
        - = 8080
      - internal
      - web
      - mysql

I'm confident that both services have been correctly deployed, see services:

root@d2e-server-1:~# docker service ls
ID             NAME          MODE         REPLICAS   IMAGE                      PORTS
hm71k8yp791d   d2e_adminer   replicated   1/1        adminer:4.6.3-standalone   
1fwzg0ud332y   d2e_mysql     replicated   1/1        mysql:5.7                  
tl1vin36sl74   d2e_traefik   replicated   1/1        traefik:v2.2               *:80->80/tcp, *:443->443/tcp

however, traefik does not detect them. The
This is the output of the dashboard in swarm:

When it was deployed with compose (only containers, no services) I had the following dashboard:

What am I doing wrong?

Invalid label.

Are you sure that traefik is running in swarm mode. The Host rule look suspect of non-swarm mode.

1 Like

Thanks! Just removed it :slight_smile: still not detecting the host though.

What do you mean the host rule?
traefik.http.routers.adminer.rule=Host( is not supposed to work with swarm mode?

Thanks @cakiwi

I'm referring to the Host rule in the dashboard screen shot, it looks like the default rule created by traefik.

Confirmed my suspicion.

Try enabling log.level=debug

Then you should see a line like this on startup:

time="2021-09-27T22:10:14Z" level=debug msg="Static configuration loaded {"global":{"checkNewVersion":true},"serversTransport":{"maxIdleConnsPerHost":200},"entryPoints":{"dashboard":{"address":":8080","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}},"web":{"address":":80","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{"redirections":{"entryPoint":{"to":"websecure","scheme":"https","permanent":true,"priority":2147483646}}},"udp":{"timeout":"3s"}},"websecure":{"address":":443","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{"tls":{}},"udp":{"timeout":"3s"}}},"providers":{"providersThrottleDuration":"2s","docker":{"watch":true,"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host({{ normalize .Name }})","exposedByDefault":true,"swarmModeRefreshSeconds":"15s"}},"api":{"dashboard":true},"log":{"level":"debug","format":"common"},"pilot":{"dashboard":true}}"

This one is missing swarmMode, I think yours is too.

1 Like

Thank you for your research @cakiwi!

If I understand well I should add a flag in my compose for my services such as:
- traefik.docker.swarmMode=true

however, this does not seem to work either... :frowning:

The setting is static configuration for traefik set on the cli, env or static configuration file. As it is set in your toml it should be running with swamMode. As you are mounting files you may need to remove the traefik service and redploy.

A better approach is to use docker config and docker secrets. Or in the case of static setting use the command line flags in your docker-compose.yaml / stack.yaml

Was your setup missing swarmMode on startup in the logs ?

1 Like

Thanks for the tips, I'll try everything out and let you know @cakiwi ! Your help is greatly appreciated :slight_smile:

you were right, I checked the logs and the swarm traefik service was not started with swarkMode. After redeployement, it actually now started as swarm:

    "global": { "checkNewVersion": true },
    "serversTransport": { "maxIdleConnsPerHost": 200 },
    "entryPoints": {
        "web": {
            "address": ":80",
            "transport": {
                "lifeCycle": { "graceTimeOut": 10000000000 },
                "respondingTimeouts": { "idleTimeout": 180000000000 }
            "forwardedHeaders": {},
            "http": {
                "redirections": {
                    "entryPoint": { "to": "websecure", "scheme": "https", "permanent": true, "priority": 2147483647 }
        "websecure": {
            "address": ":443",
            "transport": {
                "lifeCycle": { "graceTimeOut": 10000000000 },
                "respondingTimeouts": { "idleTimeout": 180000000000 }
            "forwardedHeaders": {},
            "http": {}
    "providers": {
        "providersThrottleDuration": 2000000000,
        "docker": {
            "watch": true,
            "endpoint": "unix:///var/run/docker.sock",
            "defaultRule": "Host(`{{ normalize .Name }}`)",
            "exposedByDefault": true,
            "swarmMode": true,
            "network": "web",
            "swarmModeRefreshSeconds": 15000000000
        "file": { "watch": true, "filename": "traefik_dynamic.toml" }
    "api": { "dashboard": true },
    "log": { "level": "DEBUG", "format": "common" },
    "certificatesResolvers": {
        "lets-encrypt": {
            "acme": {
                "email": "",
                "caServer": "",
                "storage": "acme.json",
                "keyType": "RSA4096",
                "tlsChallenge": {}

However, my traekif service is still giving me the error:

d2e_traefik.a@d2e-server-1 | time="2021-10-01" level=error msg="field not found, node: port " container=d2e-traefik-as providerName=docker

I've checked this issue, but since I have the following line in my deploy: labels: :
- = 80
It should be right. Maybe I'm missing something?

Double check the labels on your traefik service.

docker service inspect yourtraefikservice | jq .[].Spec.Labels
1 Like

OMG !! The output pointed me at the right direction!!! :slight_smile: The output was the following:

  "com.docker.stack.image": "traefik:v2.2",
  "com.docker.stack.namespace": "d2e",
  " ": "80"

Note the space in port . I changed the label from:
- = 80
- ""

and no more errors!

Thank you so much for your help @cakiwi !

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.