Assign only service labels on docker, and define routers in file provider without errors

Hello, I am not quite sure if I do something wrong or reach a limit of traefik.

My Goal is to assign only services per docker label and define their routers via file provider. The reason for this is, the service rarely change, but I have the ability to hot-reload their router configuration (domain, middlewares, etc)

A docker service would look like this:

  apache:
    image: httpd:latest
...
    labels:
      - "traefik.enable=true"
      - "traefik.http.services.apache.loadbalancer.server.port=80"

My docker provider config looks like that (I've tried tons of variations)

      - --providers.docker=true
      - --providers.docker.watch=true
      - --providers.docker.endpoint=tcp://sp_traefik:2375 # Use Docker Socket Proxy instead for improved security
      # - --providers.docker.network=traefik
      # - --providers.docker.swarmMode=false
      # - --providers.docker.defaultrule=Host(`{{ index .Labels "com.docker.compose.service" }}.$DOMAINNAME`) # Automatically set Host rule for services
      # - --providers.docker.defaultRule= # Kinda a hack, stops creating routers for every service
      # - --providers.docker.defaultRule=Host(`{{ .Name }}.{{ index .Labels \"customLabel\"}}.$DOMAINNAME`)
      - --providers.docker.constraints=!Label(`a.label.name`, `value`)
      - --providers.docker.allowEmptyServices=false
      - --providers.docker.exposedByDefault=false # Expose all containers to traefik

The result is that I either get auto-created routers (which I don't want), or errors in the log file:

time="2023-01-14T16:24:19+01:00" level=error msg="the service \"apache@docker\" does not exist" entryPointName=https routerName=catchNonExistentServices@file
time="2023-01-14T16:24:19+01:00" level=error msg="the service \"dozzle@docker\" does not exist" entryPointName=https routerName=dozzle@file
time="2023-01-14T16:24:19+01:00" level=error msg="the service \"apache@docker\" does not exist" entryPointName=https routerName=welcomePage@file

If I use: - --providers.docker.defaultRule= # Kinda a hack, stops creating routers for every service
the service labels work, and no unnecessary routers get created, but I have tons of those errors in the log:

time="2023-01-14T16:20:17+01:00" level=error msg="Undefined rule" providerName=docker routerName=apache-docker
time="2023-01-14T16:20:17+01:00" level=error msg="Undefined rule" routerName=dozzle-docker providerName=docker
time="2023-01-14T16:20:17+01:00" level=error msg="Undefined rule" providerName=docker routerName=error-pages-docker

So my question is, how can I tell traefik to use my services defined by labels via docker-compose but don't create any routers without spaming my log file?
My best solution so far would be, using the defaultRule= method and set warning level of log files to fatal.

PS: the only resource i found related to this topic was: Can docker labels be used without assigning a custom router or service name? which wasn't really helpful

Cheers, and thanks for everyone reading this :slight_smile:

Thanks for your interest in Traefik!

Currently, there is no easy way to solve this.

We are already aware of this use case and looking into it.

For all readers, if you are looking for this feature, please do not hesitate and add your use case to this proposal on GitHub.