Skip to content

Commit 4cfa584

Browse files
committed
Move hooks from lifecycle.md to runtime.md
Hooks are only valid in runtime.json, so we should discuss them in the runtime.json docs. I'll add appropriate links from the lifecycle docs in a bit, but linking into runtime.json is poor enough that I think it deserves its own commit. The only change here besides the copy/paste is the addition of a blank line after the Markdown headers to match the rest of the documentation. Signed-off-by: W. Trevor King <[email protected]>
1 parent 4d30c41 commit 4cfa584

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed

lifecycle.md

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,3 @@ Runs a process in a container. Can be invoked several times.
1515
Not sure we need that from runc cli. Process is killed from the outside.
1616

1717
This event needs to be captured by runc to run onstop event handlers.
18-
19-
## Hooks
20-
Hooks allow one to run code before/after various lifecycle events of the container.
21-
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.
22-
23-
Hook paths are absolute and are executed from the host's filesystem.
24-
25-
### Pre-start
26-
The pre-start hooks are called after the container process is spawned, but before the user supplied command is executed.
27-
They are called after the container namespaces are created on Linux, so they provide an opportunity to customize the container.
28-
In Linux, for e.g., the network namespace could be configured in this hook.
29-
30-
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.
31-
32-
### Post-stop
33-
The post-stop hooks are called after the container process is stopped. Cleanup or debugging could be performed in such a hook.
34-
If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
35-
36-
*Example*
37-
38-
```json
39-
"hooks" : {
40-
"prestart": [
41-
{
42-
"path": "/usr/bin/fix-mounts",
43-
"args": ["arg1", "arg2"],
44-
"env": [ "key1=value1"]
45-
},
46-
{
47-
"path": "/usr/bin/setup-network"
48-
}
49-
],
50-
"poststop": [
51-
{
52-
"path": "/usr/sbin/cleanup.sh",
53-
"args": ["-f"]
54-
}
55-
]
56-
}
57-
```
58-
59-
`path` is required for a hook. `args` and `env` are optional.

runtime.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
## Hooks
2+
3+
Hooks allow one to run code before/after various lifecycle events of the container.
4+
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.
5+
6+
Hook paths are absolute and are executed from the host's filesystem.
7+
8+
### Pre-start
9+
10+
The pre-start hooks are called after the container process is spawned, but before the user supplied command is executed.
11+
They are called after the container namespaces are created on Linux, so they provide an opportunity to customize the container.
12+
In Linux, for e.g., the network namespace could be configured in this hook.
13+
14+
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.
15+
16+
### Post-stop
17+
18+
The post-stop hooks are called after the container process is stopped. Cleanup or debugging could be performed in such a hook.
19+
If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
20+
21+
*Example*
22+
23+
```json
24+
"hooks" : {
25+
"prestart": [
26+
{
27+
"path": "/usr/bin/fix-mounts",
28+
"args": ["arg1", "arg2"],
29+
"env": [ "key1=value1"]
30+
},
31+
{
32+
"path": "/usr/bin/setup-network"
33+
}
34+
],
35+
"poststop": [
36+
{
37+
"path": "/usr/sbin/cleanup.sh",
38+
"args": ["-f"]
39+
}
40+
]
41+
}
42+
```
43+
44+
`path` is required for a hook. `args` and `env` are optional.
45+
146
## Mount Configuration
247

348
Additional filesystems can be declared as "mounts", specified in the *mounts* array. The parameters are similar to the ones in Linux mount system call. [http://linux.die.net/man/2/mount](http://linux.die.net/man/2/mount)

0 commit comments

Comments
 (0)