Skip to content

Commit 1500586

Browse files
committed
hooks: start with pre-start and post-stop hooks.
Signed-off-by: Mrunal Patel <[email protected]>
1 parent 25e30fe commit 1500586

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

runtime.md

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

1717
This event needs to be captured by oc to run onstop event handlers.
18+
19+
## Hooks
20+
Hooks allows one to run code before/after various lifecycle events of the container. The state of the container is passed to the hooks over a well-known fd, so the hooks could get the information they need to do their work.
21+
22+
The path to the hooks could be absolute or relative and are executed from the host's filesystem.
23+
If they are relative, then they are searched for within the PATH environment variable on the host.
24+
25+
26+
### Pre-start
27+
The pre-start hooks are called after the container process is started but before the user supplied command is executed. It provides an opportunity to customize the container. In Linux, for e.g., the network namespace could be configured in this hook.
28+
29+
If a hook returns a non-zero exit code, then an error is returned to the caller and the operation is aborted.
30+
For e.g., if the pre-start hooks fails, then the container isn't started and an error is returned to the
31+
caller.
32+
33+
### Post-stop
34+
The post-stop hooks are called after the container process is stopped. Cleanup or debugging could be performed in such a hook.
35+
36+
If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
37+
38+
```
39+
"hooks" : {
40+
"pre-start": [
41+
["fix-mounts", "arg1", "arg2"],
42+
["setup-network", "eth0"]
43+
],
44+
"post-stop": [
45+
["cleanup", "-f"]
46+
]
47+
}
48+
```
49+

0 commit comments

Comments
 (0)