'Why do you need "traefik.docker.network" for some service?

I have a docker swarm setup with traefik in it. I added a service (in this case, grafana and prometheus) with this label:

  grafana:
    ...
    labels:
      - "router=inbound"
      - "traefik.http.routers.grafana.entrypoints=http"
      - "traefik.http.routers.grafana.rule=Host(`grafana.localhost`)"
      - "traefik.http.routers.grafana.service=grafana"
      - "traefik.http.services.grafana.loadbalancer.server.port=3000"
      - "traefik.docker.network=inbound"
  networks:
      - inbound

  traefik:
    ...
    command:
      - --providers.docker.constraints=Label(`router`,`inbound`)
      - --providers.docker
      - --providers.docker.exposedbydefault=false
      - --entryPoints.http.address=:80
    networks:
      - inbound

Without "traefik.docker.network=inbound" in grafana labels, I can reach the service and access the UI, but it's incredibly unstable and I often got connection error. With that line, everything works smoothly.

I wonder what exactly that line does. Why is the service having connection issues (but not totally unreachable) without that line, when the container itself is already configured to be inside the same network as traefik router.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source