Allow discovering non-running Docker containers #10645
Conversation
|
Hello @acouvreur, Thank you for this contribution! The extension of the Docker provider As the service definition with a docker container isn't a really "thing" (at most a docker-compose service), that Traefik can read and rely on, multiple stopped containers providing different dynamic configurations for the same resources (routers, middleware, etc...) can co-exist, which will result as being in error and dropped because of conflicting configurations found. With docker-compose, this is mitigated if the service name never changes, as the stopped containers for the service are cleared. With other providers, the service definition is what Traefik uses to create the configuration, and because this is not possible with Docker, I am wondering if this behavior should be controlled with the same |
|
I'm interested in it too. I would like to have a custom error page for a stopped container. and it only works if the container is running or unhealthy. If the container is stopped, I just get a simple 404. |
|
It's been a while! I've reworked this all from scratch. Basically all it does now is that the container status is now reported in the structure We can talk about having a dedicated field for that feature specifically, but in my opinion this is what the feature is supposed to be.
It returns a |
allowEmptyServices for docker provider to scan non-running containers
|
Any news @rtribotte ? |
|
Hi @acouvreur, sorry for the late reply. We have given some more thought to changing the behaviour of the Also, as mentioned above, the lack of service definition in Docker is the a blocker to considering a stopped container as defining a service. So we do not think that using this option in your use case is the best option. However, we think the ability to discover a stopped container could be an opt-in feature per container by introducing a new label, WDYT? |
|
@rtribotte Thanks for your answer. Just to be sure to understand correclty, your proposition is to keep the PR of @acouvreur but with an additionnal config or label parameter like "visibleWhenStopped" with default value to false ? |
sdelicata
left a comment
There was a problem hiding this comment.
Thanks @acouvreur for this contribution!
I just made a few suggestions. Other than that LGTM
allowEmptyServices for docker provider to scan non-running containers
rtribotte
left a comment
There was a problem hiding this comment.
Hi @acouvreur,
We pushed a review commit.
We limited the impact of the option only to the Docker provider, since we identified that the allowEmptyService Swarm provider option should be enough to support the Sablier use case.
However, currently the allowEmptyService option is not working as expected (and as you mentioned it, using the LBSwarm option is the current workaround). We opened an issue for that: #12196
Thank you!
|
Can't believe it finally happend... Thank you all. I'm excited to test it out when it's available |
Crazy right? A year and a half in the making |
|
I've just tested to start a single container. |

What does this PR do?
This PR implements the
allowEmptyServicescapabilities to the Docker provider by allowing non running containers to be discovered.Motivation
Non-running containers not returning 404, but 503 instead and having the full middleware chain built and executed on requests.
Fixes #9907
Fixes #7842
More
Additional Notes
Test it yourself:
makedocker build -t traefik:test .docker compose updocker compose down whoamicurl http://localhost:8080/whoami-> 503You can add any middleware, and they will get exectued, which is the most important part.