Answer
Deterministic priority is guaranteed when you assign an explicit numeric priority to each router. If priorities differ, the router with the highest value wins. If priorities are equal, Traefik breaks the tie by load‑order: the router that was loaded (or last updated) last wins. This load‑order is deterministic as long as the static provider list and the sequence of updates do not change.
Likely explanation
Traefik merges configurations from all enabled providers into a single routing table. Each router receives a priority value (default 0). When multiple routers match a request, Traefik selects the one with the highest priority; equal priorities are resolved by the router that was processed most recently.
Confirmed facts
- In Traefik v2 and v3, Docker‑provider routers set priority via the label
traefik.http.routers..priority. - File‑provider routers set priority directly in the static YAML/TOML under
routers..priority. - The numeric values are comparable across providers.
Steps to synchronize priority
- Decide the priority you want for the overlapping route (e.g.,
10). - In the file‑provider configuration (e.g.,
traefik.yml), set:
http:
routers:
web:
rule: Host(`example.com`) && PathPrefix(`/`)
priority: 10
- Apply the same numeric value to the matching Docker container via a label:
traefik.http.routers.web.priority=10
- Ensure both providers are listed in the same static
providers section (or load a dynamic file that overrides Docker labels) so the load‑order is fixed. - Reload Traefik (or let it hot‑reload) and verify.
Verification
Access the Traefik dashboard (http://<traefik>:8080/dashboard/) and check the Routers list; each router should display the priority number you set. Perform a curl request to the target host/path and confirm the expected service responds. Changing a priority label and observing the response switch confirms the synchronization works.
Missing diagnostic detail
If the observed behavior does not match the expected priority, please provide the current priority values seen for the conflicting routers from both the Docker container (docker inspect <container> --format '{{ index .Config.Labels "traefik.http.routers.web.priority" }}') and the file‑based router (from the dashboard or static config). This detail determines whether the tie‑break rule is being applied.