feat: debug shell with a tools image for containers without a shell #30

Merged
jfro merged 1 commit from feat/14-debug-shell into main 2026-11-30 20:34:01 +00:00
Owner

Closes #14

Stacked on #29 (#13 files) → #28 (#16 engine picker); review the top commit only.

What

  • Open Debug Shell in a running container's right-click menu: a helper from a tools image (busybox:1.37 by default, "debugImage" in ~/.config/krane/settings.json to change it, e.g. alpine) joins the container's PID and network namespaces and starts in /proc/1/root, so you see its processes, its network and its files, even on distroless/scratch images.
  • Open Terminal falls back to it when the image has no sh (checked first with a detached sh -c true exec; 126/127 or an "executable file not found" error means no shell). A toast says it opened a debug shell instead.
  • The terminal runs docker [--context …] start -ai <helper> (same CLI routing as Open Terminal, via engine::cli_args()); the helper has auto_remove, so the engine removes it when the shell exits or the target stops. Never-started helpers older than a minute are swept before the next one is made.
  • Helpers follow Nye's probe (thanks): SYS_PTRACE for nonroot targets, cd in the command (runc refuses /proc/1/root as working dir), no ipc_mode, a random name suffix so several shells can be open.
  • Krane's helpers (krane.helper label: file browsing and debug shells) are left out of the Containers list and never raise notifications (a shell exiting non-zero isn't a crash).
  • Open Terminal now runs off the UI thread and reports problems as an alert; xfce4-terminal (-x) added to the known terminals.

Tests

  • 4 unit tests (helper body, shell cmd, "no shell" error parsing, helpers never alert); local CI (fmt, clippy ×2, build, test ×2, mock build) green.
  • cargo test live_debug_shell -- --ignored passes on Docker 29.9 and Podman 5.4: a pause container running as uid 65532 has no shell; a helper reads its /pause, sees its PID 1, and is swept/removed correctly.
  • By hand on Xfce against Docker: Open Terminal on a shell-less container fell back to the debug shell (screenshot), exit 3 closed it with no notification and no helper left; Open Terminal on a normal container still opens docker exec.

Screenshots

Menu (mock data):
debug menu

Debug shell in a distroless pause container (real engine):
debug shell

README features and layout updated. No screenshot scene changes: the menu isn't in scripts/screenshots.sh.

Closes #14 Stacked on #29 (#13 files) → #28 (#16 engine picker); review the top commit only. **What** - **Open Debug Shell** in a running container's right-click menu: a helper from a tools image (`busybox:1.37` by default, `"debugImage"` in `~/.config/krane/settings.json` to change it, e.g. `alpine`) joins the container's PID and network namespaces and starts in `/proc/1/root`, so you see its processes, its network and its files, even on distroless/scratch images. - **Open Terminal falls back to it** when the image has no `sh` (checked first with a detached `sh -c true` exec; 126/127 or an "executable file not found" error means no shell). A toast says it opened a debug shell instead. - The terminal runs `docker [--context …] start -ai <helper>` (same CLI routing as Open Terminal, via `engine::cli_args()`); the helper has `auto_remove`, so the engine removes it when the shell exits or the target stops. Never-started helpers older than a minute are swept before the next one is made. - Helpers follow Nye's probe (thanks): `SYS_PTRACE` for nonroot targets, `cd` in the command (runc refuses `/proc/1/root` as working dir), no `ipc_mode`, a random name suffix so several shells can be open. - Krane's helpers (`krane.helper` label: file browsing and debug shells) are left out of the Containers list and never raise notifications (a shell exiting non-zero isn't a crash). - Open Terminal now runs off the UI thread and reports problems as an alert; `xfce4-terminal` (`-x`) added to the known terminals. **Tests** - 4 unit tests (helper body, shell cmd, "no shell" error parsing, helpers never alert); local CI (fmt, clippy ×2, build, test ×2, mock build) green. - `cargo test live_debug_shell -- --ignored` passes on Docker 29.9 and Podman 5.4: a `pause` container running as uid 65532 has no shell; a helper reads its `/pause`, sees its PID 1, and is swept/removed correctly. - By hand on Xfce against Docker: Open Terminal on a shell-less container fell back to the debug shell (screenshot), `exit 3` closed it with no notification and no helper left; Open Terminal on a normal container still opens `docker exec`. **Screenshots** Menu (mock data): ![debug menu](https://git.knope.dev/attachments/238543e3-def4-4b7e-9d8a-33c2ce2ff863) Debug shell in a distroless `pause` container (real engine): ![debug shell](https://git.knope.dev/attachments/e5a65731-a38c-43f6-8c77-a44a49417952) README features and layout updated. No screenshot scene changes: the menu isn't in `scripts/screenshots.sh`.
feat: debug shell with a tools image for containers without a shell
All checks were successful
CI / test (pull_request) Successful in 5m6s
c9a74cd32d
Closes #14
jfro force-pushed feat/14-debug-shell from c9a74cd32d
All checks were successful
CI / test (pull_request) Successful in 5m6s
to 92742e267c
All checks were successful
CI / test (pull_request) Successful in 5m28s
CI / test (push) Successful in 5m3s
2026-11-30 20:18:11 +00:00
Compare
jfro changed target branch from feat/13-file-browser to main 2026-11-30 20:33:58 +00:00
jfro merged commit 92742e267c into main 2026-11-30 20:34:01 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/krane!30
No description provided.