Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout to --wait option #10269

Closed
mitasov-ra opened this issue Feb 11, 2023 · 8 comments · Fixed by #10276
Closed

Add timeout to --wait option #10269

mitasov-ra opened this issue Feb 11, 2023 · 8 comments · Fixed by #10276

Comments

@mitasov-ra
Copy link

mitasov-ra commented Feb 11, 2023

Description

Assume I have the docker-compose.yml file with single service foo which guaranteed to fail immediately after I start it.

If I run

docker-compose up --wait

the command will wait forever for Healthy status of foo. Literally forever.

I think the lack of --wait-timeout or just --wait <timeout> option renders this behaviour utterly useless.

Yes, I foresee one can suggest wrap docker-compose up --wait in some code with timeout or use some command (like timeout or so), but why then we have healthcheck with all the interval, timeout and retries configurations?

It's really disappointing to see such a good feature being so poorly implemented.

P.S. Also, it seems to be a good idea not only implement timeout configuration but also add possibility to specify list of services to be waited for. And I think there's more possible enhancements.

P.P.S. On second thought, if --wait fails on any configured healthcheck failure then it already can be called very useful. But again, what if there's no configured healthchecks?

@laurazard
Copy link
Member

Hiya @mitasov-ra, thanks for the report.

Regarding what you mentioned (Compose waiting forever when using --wait with a service that immediately fails), #10209 should address it. I believe fixing that should address your issues with the usability of --wait.

@ndeloof
Copy link
Contributor

ndeloof commented Feb 13, 2023

This indeed has been fixed for container to immediately exit on start.
--wait is designed to keep up command running until the whole stack is started & healthy. If none of the selected service has healthcheck configured, it just check container successfully started, which is a bare minimum sanity check.

@ValiDrv
Copy link

ValiDrv commented Feb 13, 2023

I'm having the same issue which could be solved with a --wait-timeout.

For example: We deploy on multiple servers, and one had a hiccup that failed the healthcheck and could not recover without manual intervention (picture disk failure). So the --wait would wait forever, with no way to take action.

If we had a --wait-timeout, we could have taken some actions after X seconds, something like bringing down the new service, which is now stuck running making health checks.

@jamshid
Copy link

jamshid commented Apr 4, 2023

Compose v2.17 breaks scripts using docker-compose up --timeout N. Is that intentional?
I guess scripts should use -t to work with both 2.15 and 2.17. Now -t means --wait-timeout.

@ndeloof
Copy link
Contributor

ndeloof commented Apr 4, 2023

flag was indeed renamed by mistake (and nobody noticed during PR review 😰), still -t is the same old timeout set for container shutdown.

@jamshid
Copy link

jamshid commented Apr 4, 2023

Thanks no problem it happens. And I was happy when I realized I could change scripts to -t for compatibility. Maybe a release note can be added about that.

Hopefully you can rename back to --timeout (and no one uses --waitTimeout) before the next compose release in Docker for Desktop.

@ndeloof
Copy link
Contributor

ndeloof commented Apr 4, 2023

Sure, I added a note on https://github.com/docker/compose/releases/tag/v2.17.2

AlekSi added a commit to AlekSi/FerretDB that referenced this issue Apr 5, 2023
jimsihk added a commit to jimsihk/alpine-php-nginx that referenced this issue Apr 7, 2023
jimsihk added a commit to jimsihk/alpine-moodle that referenced this issue Apr 7, 2023
jimsihk added a commit to jimsihk/alpine-moodle that referenced this issue Apr 7, 2023
jimsihk added a commit to jimsihk/alpine-moodle that referenced this issue Apr 7, 2023
jimsihk added a commit to jimsihk/alpine-php-nginx that referenced this issue Apr 7, 2023
@mgulyas42
Copy link

mgulyas42 commented Apr 24, 2024

Could you tell me this - -wait-timeout when start the timer? Does it start the timer immediately or does it wait for pulling docker images and then start?

Edit: As far as I see its starts after the container creation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants