Skip to content

- Exclude one-off compose containers from Traefik routing#18

Open
MichalMyskow wants to merge 1 commit into
mainfrom
traefik-exclude-compose-oneoff-containers
Open

- Exclude one-off compose containers from Traefik routing#18
MichalMyskow wants to merge 1 commit into
mainfrom
traefik-exclude-compose-oneoff-containers

Conversation

@MichalMyskow

Copy link
Copy Markdown
Member

Problem

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.

Fix

Docker stamps one-off (compose run) containers with com.docker.compose.oneoff=True (normal up services are False). 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.

- constraints: "Label(`...`,`true`)"
+ constraints: "Label(`...`,`true`) && !Label(`com.docker.compose.oneoff`,`True`)"

Template-only change (traefik.yml.example); placeholders preserved.

Verification

With a live compose run container present, the real service went from ~50% 502 flapping to 12/12 → 200. Normal up services are unaffected (they carry oneoff=False), so it's backwards-compatible.

`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.
@MichalMyskow MichalMyskow requested a review from a team as a code owner July 9, 2026 10:35
@MichalMyskow MichalMyskow requested a review from mtracz July 9, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant