Skip to content

Commit f728537

Browse files
author
Roy Lin
committed
fix(box): a non---rm box survives stop (keeps dir+logs) like Docker
A foreground `run` without `--rm` wiped its entire box dir (logs included) on exit via destroy_with_options (non-persistent boxes are removed), while keeping the state record — so the box showed in `ps -a` but `logs`/`start` found nothing. Docker keeps a stopped container (and its logs) until `rm`. Make a box persistent unless `--rm`: `persistent = --persistent || !--rm`. Persistent only affects teardown cleanup (keep the box dir + overlay upper, the overlay is unmounted either way — no mount leak); it has no boot-time effect. `--rm` boxes and CRI pods stay non-persistent (removed on teardown, no pod-dir leak), and `rm` force-removes regardless (cleanup_removed_box). KVM-verified: `run` (no --rm) -> `logs` shows the output after exit and the box is in `ps -a`; `run --rm` -> 0 boxes after; `rm` -> removed; detached logs still complete. Completes the `run`+`logs` workflow alongside the shim-owned log processor.
1 parent 8794cb5 commit f728537

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/cli/src/commands/run.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,11 @@ fn build_box_config(
473473
vsock_port: args.sidecar_vsock_port,
474474
env: vec![],
475475
}),
476-
persistent: args.common.persistent,
476+
// A box without `--rm` survives its stop like a Docker stopped
477+
// container: keep its dir (logs + overlay upper) so `logs`/`start` work
478+
// afterwards. `--rm` boxes and CRI pods stay non-persistent (removed on
479+
// teardown). `rm` force-removes either way (cleanup_removed_box).
480+
persistent: args.common.persistent || !args.rm,
477481
..Default::default()
478482
})
479483
}

0 commit comments

Comments
 (0)