|
5 | 5 | Lifecycle hooks allow custom events for different points in a container's runtime. |
6 | 6 | Presently there are `Prestart`, `Poststart` and `Poststop`. |
7 | 7 |
|
8 | | -* [`Prestart`](#pre-start) is a list of hooks to be run before the container process is executed |
9 | | -* [`Poststart`](#post-start) is a list of hooks to be run immediately after the container process is started |
10 | | -* [`Poststop`](#post-stop) is a list of hooks to be run after the container process exits |
| 8 | +* [`Prestart`](#prestart) is a list of hooks to be run before the container process is executed |
| 9 | +* [`Poststart`](#poststart) is a list of hooks to be run immediately after the container process is started |
| 10 | +* [`Poststop`](#poststop) is a list of hooks to be run after the container process exits |
11 | 11 |
|
12 | 12 | Hooks allow one to run code before/after various lifecycle events of the container. |
13 | 13 | Hooks MUST be called in the listed order. |
14 | 14 | The state of the container is passed to the hooks over stdin, so the hooks could get the information they need to do their work. |
15 | 15 |
|
16 | 16 | Hook paths are absolute and are executed from the host's filesystem. |
17 | 17 |
|
18 | | -### Pre-start |
| 18 | +### Prestart |
19 | 19 |
|
20 | 20 | The pre-start hooks are called after the container process is spawned, but before the user supplied command is executed. |
21 | 21 | They are called after the container namespaces are created on Linux, so they provide an opportunity to customize the container. |
22 | 22 | In Linux, for e.g., the network namespace could be configured in this hook. |
23 | 23 |
|
24 | 24 | 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. |
25 | 25 |
|
26 | | -### Post-start |
| 26 | +### Poststart |
27 | 27 |
|
28 | 28 | The post-start hooks are called after the user process is started. |
29 | 29 | For example this hook can notify user that real process is spawned. |
30 | 30 |
|
31 | 31 | If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed. |
32 | 32 |
|
33 | | -### Post-stop |
| 33 | +### Poststop |
34 | 34 |
|
35 | 35 | The post-stop hooks are called after the container process is stopped. |
36 | 36 | Cleanup or debugging could be performed in such a hook. |
|
0 commit comments