Skip to content

Conversation

@ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Oct 4, 2024

Description

documentation for docker/compose#12166

Related issues or tickets

Reviews

  • Technical review
  • Editorial review
  • Product review

@ndeloof ndeloof requested a review from aevesdocker as a code owner October 4, 2024 12:57
@netlify
Copy link

netlify bot commented Oct 4, 2024

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 8b96dfb
🔍 Latest deploy log https://app.netlify.com/sites/docsdocker/deploys/670e8c225939b10009f69518
😎 Deploy Preview https://deploy-preview-21061--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the area/compose Relates to docker-compose.yml spec or docker-compose binary label Oct 4, 2024
@ndeloof ndeloof force-pushed the hooks branch 2 times, most recently from f8514f6 to ca7443d Compare October 7, 2024 09:34
@ndeloof ndeloof requested review from glours and jhrotko October 7, 2024 09:34
Copy link
Contributor

@aevesdocker aevesdocker left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

@jhrotko jhrotko Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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]>
Copy link
Contributor

@aevesdocker aevesdocker left a 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?

@ndeloof
Copy link
Contributor Author

ndeloof commented Oct 15, 2024

better get this published with the compose release

@aevesdocker aevesdocker merged commit 9fed920 into docker:main Oct 29, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/compose Relates to docker-compose.yml spec or docker-compose binary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants