mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #2825 from lifubang/nodelete
proposal: add --keep to runc run
This commit is contained in:
@@ -42,6 +42,12 @@ container to inherit the calling processes session key.
|
||||
: Pass _N_ additional file descriptors to the container (**stdio** +
|
||||
**$LISTEN_FDS** + _N_ in total). Default is **0**.
|
||||
|
||||
**--keep**
|
||||
: Keep container's state directory and cgroup. This can be helpful if a user
|
||||
wants to check the state (e.g. of cgroup controllers) after the container has
|
||||
exited. If this option is used, a manual **runc delete** is needed afterwards
|
||||
to clean an exited container's artefacts.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
**runc**(8).
|
||||
|
||||
@@ -40,6 +40,10 @@ command(s) that get executed on start, edit the args parameter of the spec. See
|
||||
Name: "detach, d",
|
||||
Usage: "detach from the container's process",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "keep",
|
||||
Usage: "do not delete the container after it exits",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "pid-file",
|
||||
Value: "",
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
function setup() {
|
||||
setup_hello
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
teardown_bundle
|
||||
}
|
||||
|
||||
@test "runc run" {
|
||||
runc run test_hello
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
runc state test_hello
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
@test "runc run --keep" {
|
||||
runc run --keep test_run_keep
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
testcontainer test_run_keep stopped
|
||||
|
||||
runc state test_run_keep
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
runc delete test_run_keep
|
||||
|
||||
runc state test_run_keep
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
|
||||
@test "runc run --keep (check cgroup exists)" {
|
||||
# for systemd driver, the unit's cgroup path will be auto removed if container's all processes exited
|
||||
requires no_systemd
|
||||
|
||||
[[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup
|
||||
|
||||
set_cgroups_path
|
||||
|
||||
runc run --keep test_run_keep
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
testcontainer test_run_keep stopped
|
||||
|
||||
runc state test_run_keep
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# check that cgroup exists
|
||||
check_cgroup_value "pids.max" "max"
|
||||
|
||||
runc delete test_run_keep
|
||||
|
||||
runc state test_run_keep
|
||||
[ "$status" -ne 0 ]
|
||||
}
|
||||
+1
-1
@@ -439,7 +439,7 @@ func startContainer(context *cli.Context, spec *specs.Spec, action CtAct, criuOp
|
||||
|
||||
r := &runner{
|
||||
enableSubreaper: !context.Bool("no-subreaper"),
|
||||
shouldDestroy: true,
|
||||
shouldDestroy: !context.Bool("keep"),
|
||||
container: container,
|
||||
listenFDs: listenFDs,
|
||||
notifySocket: notifySocket,
|
||||
|
||||
Reference in New Issue
Block a user