Skip to content

Commit eab2bf1

Browse files
committed
runtime: Document args[0] and the no-usable-args fallback
This follows Python's API, which has 'args' and 'executable' (our PATH) for Popen [1]). That allows most users (who don't need to distinguish between args[0] and the executable path) to just use args, while still providing a means to make that distinction (set 'path') for folks who do need it. This restores the ability to explicitly set args[0] independent of the path, which was requested in opencontainers#34 [2] and ack-ed by Micheal [3] and Mrunal [4], but didn't match the examples that landed with opencontainers#34. [1]: https://docs.python.org/3/library/subprocess.html#subprocess.Popen [2]: opencontainers#34 (comment) [3]: opencontainers#34 (comment) [4]: opencontainers#34 (comment) Signed-off-by: W. Trevor King <[email protected]>
1 parent cbda521 commit eab2bf1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

runtime.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,24 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
7575
"hooks" : {
7676
"prestart": [
7777
{
78-
"path": "/usr/bin/fix-mounts",
79-
"args": ["arg1", "arg2"],
78+
"args": ["/usr/bin/fix-mounts", "arg1", "arg2"],
8079
"env": [ "key1=value1"]
8180
},
8281
{
83-
"path": "/usr/bin/setup-network"
82+
"path": "/usr/bin/setup-network",
83+
"args": ["net.eth1", "start"],
8484
}
8585
],
8686
"poststop": [
8787
{
88-
"path": "/usr/sbin/cleanup.sh",
89-
"args": ["-f"]
88+
"args": ["/usr/sbin/cleanup.sh", "-f"]
9089
}
9190
]
9291
}
9392
```
9493

95-
`path` is required for a hook.
96-
`args` and `env` are optional.
94+
`args` is passed to the executable, and includes the command as `args[0]` (which MUST be an absolute path).
95+
`path` is optional, but if set it MUST be an absolute path.
96+
When set, it takes precedence over `args[0]` when selecting for the executable, but it does not effect the arguments passed to that executable.
97+
For example, the `setup-network` script above will still have `net.eth` as `args[0]`.
98+
`env` is optional.

0 commit comments

Comments
 (0)