Skip to content

lifecycle hooks - #21061

Merged
aevesdocker merged 1 commit into
docker:mainfrom
ndeloof:hooks
Oct 29, 2024
Merged

lifecycle hooks#21061
aevesdocker merged 1 commit into
docker:mainfrom
ndeloof:hooks

Conversation

@ndeloof

Copy link
Copy Markdown
Contributor

Description

documentation for docker/compose#12166

Related issues or tickets

Reviews

  • Technical review
  • Editorial review
  • Product review

@netlify

netlifyBot commented Oct 4, 2024

Copy link
Copy Markdown

Deploy Preview for docsdocker ready!

NameLink
🔨 Latest commit8b96dfb
🔍 Latest deploy loghttps://app.netlify.com/sites/docsdocker/deploys/670e8c225939b10009f69518
😎 Deploy Previewhttps://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-actionsgithub-actionsBot added the area/compose Relates to docker-compose.yml spec or docker-compose binary label Oct 4, 2024
@ndeloof
ndeloofforce-pushed the hooks branch 2 times, most recently from f8514f6 to ca7443dCompareOctober 7, 2024 09:34
@ndeloof
ndeloof requested review from glours and jhrotkoOctober 7, 2024 09:34

@aevesdockeraevesdocker left a comment

Copy link
Copy Markdown
Contributor

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?

Comment threadcontent/manuals/compose/how-tos/lifecycle.md Outdated
Comment threadcontent/manuals/compose/how-tos/lifecycle.md
Comment threadcontent/manuals/compose/how-tos/lifecycle.md Outdated
Comment threadcontent/manuals/compose/how-tos/lifecycle.md
Comment threadcontent/manuals/compose/how-tos/lifecycle.md Outdated
Comment threadcontent/manuals/compose/how-tos/lifecycle.md Outdated

## Services lifecycle hooks

As Docker Compose run a service container, the actual command being ran is managed

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

@jhrotkojhrotkoOct 11, 2024

Copy link
Copy Markdown
Contributor

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.

Comment threadcontent/manuals/compose/how-tos/lifecycle.md
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

@aevesdockeraevesdocker left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

better get this published with the compose release

@aevesdocker
aevesdocker merged commit 9fed920 into docker:mainOct 29, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ndeloof@jhrotko@aevesdocker