Add option to wait for docker before starting#1705
Merged
amir20 merged 3 commits intoamir20:masterfrom Apr 3, 2022
c-w:retry-start
Merged
Add option to wait for docker before starting#1705amir20 merged 3 commits intoamir20:masterfrom c-w:retry-start
amir20 merged 3 commits intoamir20:masterfrom
c-w:retry-start
Conversation
Contributor
Author
|
Note that I had to push a change to the |
Owner
|
Interesting use case. I never had it happen. But it makes sense. I'll review later. |
amir20
reviewed
Apr 2, 2022
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.
What does this pull request do?
This pull request adds a new configuration option
DOZZLE_WAIT_FOR_DOCKERwhich if set will defer the server start until the connection to docker is healthy.Why is this useful?
In some environments, the docker connection isn't via a socket file but instead via tcp, for example if we're connecting to a remote docker host or if we're using a proxy to only allow selective access to docker APIs for security reasons. In these scenarios, the docker host may or may not be ready to serve requests at the time that dozzle starts. To simplify deployments in such an environment, it's very useful if dozzle can "self heal" and only start talking to the docker host once the docker host is ready for connections.
Of course it would also be possible to perform an external health check before starting the dozzle container, but this adds non-trivial complexity to the orchestration especially as the the dozzle container doesn't contain a shell so we couldn't for example override the entrypoint to a loop like
sh -c "while ! exec /dozzle; do sleep 5; done". Other tools that talk to the docker host (e.g. Traefik) implement this sort of "self heal" mechanism so I believe it would be neat if dozzle could also do this, especially as the added code complexity is quite minor.How can I test these changes?
Create a docker-compose file that defines dozzle and the docker socket proxy:
Now start dozzle via
docker-compose up --build dozzleand you will notice that the server waits to start up since the docker connection can't be established. Now start the docker socket proxy viadocker-compose up -d docker-proxyand you will notice that dozzle now starts the server.