Skip to content

Commit

Permalink
Add post-start hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
  • Loading branch information
LK4D4 committed Sep 28, 2015
1 parent 03bf64f commit 2c0d9a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions runtime-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Lifecycle hooks allow custom events for different points in a container's runtim
Presently there are `Prestart` and `Poststop`.

* [`Prestart`](#pre-start) is a list of hooks to be run before the container process is executed
* [`Poststart`](#post-start) is a list of hooks to be run immediately after process in container started
* [`Poststop`](#post-stop)is a list of hooks to be run after the container process exits

Hooks allow one to run code before/after various lifecycle events of the container.
Expand All @@ -22,6 +23,13 @@ In Linux, for e.g., the network namespace could be configured in this hook.

If a hook returns a non-zero exit code, then an error including the exit code and the stderr is returned to the caller and the container is torn down.

### Post-start

The post-start hooks are called after the user process is started.
It can be used for notifying user that real process is spawned.

If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.

### Post-stop

The post-stop hooks are called after the container process is stopped.
Expand All @@ -42,6 +50,11 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
"path": "/usr/bin/setup-network"
}
],
"poststart": [
{
"path": "/usr/bin/notify-start",
},
],
"poststop": [
{
"path": "/usr/sbin/cleanup.sh",
Expand Down
2 changes: 2 additions & 0 deletions runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type Hooks struct {
// Prestart is a list of hooks to be run before the container process is executed.
// On Linux, they are run after the container namespaces are created.
Prestart []Hook `json:"prestart"`
// Poststart is a list of hooks to be run after the container process is started.
Poststart []Hook `json:"poststart"`
// Poststop is a list of hooks to be run after the container process exits.
Poststop []Hook `json:"poststop"`
}
Expand Down

0 comments on commit 2c0d9a3

Please sign in to comment.