commit
023c751ee4
|
@ -3,9 +3,10 @@
|
||||||
## Hooks
|
## Hooks
|
||||||
|
|
||||||
Lifecycle hooks allow custom events for different points in a container's runtime.
|
Lifecycle hooks allow custom events for different points in a container's runtime.
|
||||||
Presently there are `Prestart` and `Poststop`.
|
Presently there are `Prestart`, `Poststart` and `Poststop`.
|
||||||
|
|
||||||
* [`Prestart`](#pre-start) is a list of hooks to be run before the container process is executed
|
* [`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 the container process is started
|
||||||
* [`Poststop`](#post-stop)is a list of hooks to be run after the container process exits
|
* [`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.
|
Hooks allow one to run code before/after various lifecycle events of the container.
|
||||||
|
@ -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.
|
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.
|
||||||
|
For example this hook can notify 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
|
### Post-stop
|
||||||
|
|
||||||
The post-stop hooks are called after the container process is stopped.
|
The post-stop hooks are called after the container process is stopped.
|
||||||
|
@ -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"
|
"path": "/usr/bin/setup-network"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"poststart": [
|
||||||
|
{
|
||||||
|
"path": "/usr/bin/notify-start",
|
||||||
|
},
|
||||||
|
],
|
||||||
"poststop": [
|
"poststop": [
|
||||||
{
|
{
|
||||||
"path": "/usr/sbin/cleanup.sh",
|
"path": "/usr/sbin/cleanup.sh",
|
||||||
|
|
|
@ -22,6 +22,8 @@ type Hooks struct {
|
||||||
// Prestart is a list of hooks to be run before the container process is executed.
|
// 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.
|
// On Linux, they are run after the container namespaces are created.
|
||||||
Prestart []Hook `json:"prestart"`
|
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 is a list of hooks to be run after the container process exits.
|
||||||
Poststop []Hook `json:"poststop"`
|
Poststop []Hook `json:"poststop"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue