-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Description
Problem
I found postgres image can't block dependent startup, which make dependent start up too early.
Actual
If dependent accept client at early time, dependent failed.
Expected
After postgres ready, dependent should not startup and accept client.
Try
-
Add
/docker-entrypoint-initdb.d/wait.sh, which does not block dependent. -
Overwrite command, which does not block dependent.
-
Besides, when overwrite entry/command, sometimes you may need to know what is the original entry/command, and call these HARD CODED command in a very ugly way.
-
https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y
I found .depends_on.X.condition works, but not very graceful to solve wait-for-container-x-before-starting-y.
-
If
.intervalbig, run.healthcheck.testlate, startdependentlate, not very ideal. -
If
.intervalsmall, run.healthcheck.testtoo many times, not very graceful.
Workaround
Below is my workaround.
foo:
...
depends_on:
bar:
condition: service_healthy
...
bar:
...
tmpfs:
- /tmp
healthcheck:
test: 'if [ -e /tmp/first_run ]; then sleep 24h; else touch /tmp/first_run; bash /script/wait.sh; fi'
timeout: 25h
interval: 1sFeat
Above workaround I still don't think very ideal, so I opened a feat.
Enhance healthcheck behavior like lifecyle.
foo:
...
depends_on:
bar:
condition: service_lifecycle_bootstrap
...
bar:
...
lifecycle:
bootstrap: 'bash /script/wait.sh'Related
Additional
Are there lifecyle support within container ecosystem?
Yes, vscode devcontainer support lifecycle.
initializeCommandonCreateCommandupdateContentCommandpostCreateCommandpostStartCommandpostAttachCommand