Skip to content

Commit d086c7e

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

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

runtime.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,32 @@ 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+
If a hook returns a non-zero exit code, then an error is returned to the caller and the operation is aborted.
26+
For e.g., if the pre-start hooks fails, then the container isn't started and an error is returned to the
27+
caller.
28+
29+
### Pre-start
30+
The pre-start hooks are called after the container process is started but before the user supplied command is execed. It provides an opportunity to customize the container. In Linux, for e.g., the network namespace could be configured in these hook.
31+
32+
### Post-stop
33+
The post-stop hook are called after the container process is stopped. Cleanup or debugging could be performed in such a hook.
34+
35+
```
36+
"hooks" : {
37+
"pre-start": [
38+
["fix-mounts", "arg1", "arg2"],
39+
["setup-network", "eth0"]
40+
],
41+
"post-stop": [
42+
["cleanup", "-f"]
43+
]
44+
}
45+
```
46+

0 commit comments

Comments
 (0)