-
Notifications
You must be signed in to change notification settings - Fork 8k
lifecycle hooks #21061
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
lifecycle hooks #21061
Conversation
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
f8514f6 to
ca7443d
Compare
aevesdocker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ndeloof, thanks for the PR
With ChatGPT helping my understanding, I've provided an iteration of your draft that expands the explanation and uses slightly simpler language. Let me know what you think.
Also I noticed the Compose spec updates https://github.com/compose-spec/compose-spec/pull/538/files. Can we get that added in here too as part of this PR?
|
|
||
| ## Services lifecycle hooks | ||
|
|
||
| As Docker Compose run a service container, the actual command being ran is managed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| As Docker Compose run a service container, the actual command being ran is managed | |
| As Docker Compose runs a service container, the actual command being ran is managed |
| ## Services lifecycle hooks | ||
|
|
||
| As Docker Compose run a service container, the actual command being ran is managed | ||
| by the combination of `entrypoint` and `command` as documented [here](https://docs.docker.com/engine/containers/run/#default-entrypoint). Those ley you manage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| by the combination of `entrypoint` and `command` as documented [here](https://docs.docker.com/engine/containers/run/#default-entrypoint). Those ley you manage | |
| by the combination of `entrypoint` and `command` as documented [here](https://docs.docker.com/engine/containers/run/#default-entrypoint). These let you manage |
| As Docker Compose run a service container, the actual command being ran is managed | ||
| by the combination of `entrypoint` and `command` as documented [here](https://docs.docker.com/engine/containers/run/#default-entrypoint). Those ley you manage | ||
| container setup and termination, catching SITERM signal to process a graceful shutdown. In some circumstances anyway it is easier to consider those a separate | ||
| command to be introduced as lifecycle hooks, to be ran just after the container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what you mean here -
In some circumstances anyway it is easier to consider those a separate
command to be introduced as lifecycle hooks, to be ran just after the container
is started, or just before Compose stop it.
Could you rephrase it?
| command to be introduced as lifecycle hooks, to be ran just after the container | ||
| is started, or just before Compose stop it. | ||
|
|
||
| Another benefit for lifecycle hooks, is that hook command can run with additional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: instead of
Another benefit for lifecycle hooks, is that hook command can run with additional privileges
->
Another advantage of lifecycle hooks is the ability to run hook commands with elevated privileges...
|
|
||
| ### Post-Start hooks | ||
|
|
||
| Post-Start lifecycle hooks are ran after container has been started. There's no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no guarantee on the timing hook executes while the container entrypoint is ran.
to
The timing of the hook execution is not guaranteed while the container's entrypoint is running.
|
|
||
| Pre-Stop lifecycle hooks are ran before an explicit request to stop container by a | ||
| compose command, either `docker compose down` or interrupting `docker compose up` | ||
| with Ctrl+C. Hook won't execute if container stops on its own or is killed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| with Ctrl+C. Hook won't execute if container stops on its own or is killed. | |
| with Ctrl+C. The hook execution timing is not assured during the execution of the container's entrypoint. |
Signed-off-by: Nicolas De Loof <[email protected]>
aevesdocker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Want this to be published now or with the compose release?
|
better get this published with the compose release |
Description
documentation for docker/compose#12166
Related issues or tickets
Reviews