- Exclude one-off compose containers from Traefik routing#18
Open
MichalMyskow wants to merge 1 commit into
Open
- Exclude one-off compose containers from Traefik routing#18MichalMyskow wants to merge 1 commit into
MichalMyskow wants to merge 1 commit into
Conversation
`docker compose run` containers inherit their service's labels, including `traefik.blumilk.local.environment`, so Traefik registers them as extra backends for that service's routers. Such one-off containers serve no HTTP (e.g. JetBrains docker-compose interpreters spawn them to run node/php for the language service), so requests round-robined to them return intermittent 502s / CORS failures on the real service. Docker stamps one-off (`compose run`) containers with `com.docker.compose.oneoff=True` (normal `up` services are `False`), so adding `&& !Label(com.docker.compose.oneoff, True)` to the docker provider constraint makes Traefik ignore them while still routing to the real, long-lived service containers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
docker compose runcontainers inherit their service's labels, includingtraefik.blumilk.local.environment, so Traefik registers them as extra backends for that service's routers. Such one-off containers serve no HTTP (e.g. JetBrains docker-compose interpreters spawn them to runnode/phpfor the language service), so requests round-robined to them return intermittent 502s / CORS failures on the real service.Fix
Docker stamps one-off (
compose run) containers withcom.docker.compose.oneoff=True(normalupservices areFalse). Adding&& !Label(com.docker.compose.oneoff, True)to the docker provider constraint makes Traefik ignore them while still routing to the real, long-lived service containers.Template-only change (
traefik.yml.example); placeholders preserved.Verification
With a live
compose runcontainer present, the real service went from ~50% 502 flapping to 12/12 → 200. Normalupservices are unaffected (they carryoneoff=False), so it's backwards-compatible.