Browse a container's or volume's files #13
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
OrbStack lets you browse files in containers and volumes. Krane has no way to see files without a shell.
What
GET /containers/{id}/archive), so it works with remote engines and containers with no shell.PUT /archive).File-browser approach (research by Nye, tested against a real engine)
Krane #13 file browser: how to build it (Nye, tested Nov 30)
Tested with bollard 0.20 on Docker 26.1.5 (API 1.45) and rootless Podman 5.4.2, against: busybox
(running, with a volume holding a 200 MB file, symlinks, odd names), registry.k8s.io/pause (running,
scratch image, user 65535), distroless/static nonroot (created, never started), busybox (created),
mealie (exited, 1 GB image). Probe: issue13-probe.rs (+ .Cargo.toml):
probe13 <ctr> stat|ls|cat|put <path> [max|file].Helper listing script: issue13-helper-ls.sh.
Results
get_container_archive_info)/of busybox = 214 MB / 0.47 s (the volume's 200 MB file),/of mealie (exited) = 1.07 GB / 8.9 s/proc/1/root<dir>)<vol>:/v:ro(never started) + archive APIdocker exec lsRecommended design
Backend
src/files.rs, shaped likewindow/logs.rs(aFilesSessionwhose Drop aborts its tasksand removes its helper). Use the shared client from #16.
no shell, stopped containers.
file_modebits (Go FileMode: dir1<<31, symlink1<<27). Don't infer symlinkfrom
link_target: Podman fills it with the path itself for plain files and dirs.tarunpack_in(refuses
../absolute escapes) or save as .tar. Progress from stat size.not find the file", 500 "extraction point is not a directory", 500 "mounted volume is marked read-only".
subtree including volumes (a running Postgres's
/would stream the whole database).Helper = same image/options as #14:
busybox:1.37,pid_mode: container:<id>,cap_add: [SYS_PTRACE](needed for nonroot targets),auto_remove, unique name, labelkrane.helper=files,cmd
sleep infinity. Start once when the Files tab opens; each navigation is one exec ofissue13-helper-ls.sh (
sh -c "$SCRIPT" sh <dir>), which prints NUL-separatedtype|size|mode|mtime|uid, name, link target (names with spaces/newlines tested). Helper dies byitself when the target stops (tested); remove it when the tab/selection changes; sweep the label at startup.
/archive, read headers, emit depth-1 entries as they stream (tar order is sorted, so a partial
list is a correct alphabetical prefix). Cap it (e.g. 256 MB or 10 s), then show the partial list
with "Too big to list while stopped; start the container or open a subfolder". Cancel on navigate.
<vol>:/v:roandsleep infinityand use the same execlisting with root
/v(instead of/proc/1/root); archive API on that helper for preview/copy.If you create a never-started helper from an image with no CMD (distroless), pass a dummy cmd:
create fails with "no command specified" otherwise.
(
~/.local/share/containers/storage/volumes/<v>/_data) yes; rootful Docker (/var/lib/dockeris 0710 root) no. Check with access(), hide the action otherwise.
Symlinks
link/(trailing slash) follows it.
link_targetis already resolved inside the container (sublink -> subgives/data/sub).Use that to navigate/preview.
/proc/1/root: absolute targets resolve against the helper's root(
/data/abs -> /only-in-targetgave "No such file" via the helper). Show the link and its targetfrom the listing; on click, stat via the archive API and go to the resolved path.
UI to reuse
DetailPane.qmlalready has the segmented switcher (Info, Logs;pane.tab,app.requestedTab): add "Files" as tab 2.ResourceDetail.qml(used by VolumesPage) has no tabs: add the same switcher or a Filessection there. New
FileBrowser.qml(breadcrumb + rows in ResourceRow style + preview pane),listed in build.rs.
QtQuick.DialogsFileDialog (not used in the repo yet; check theruntime Qt package includes it).
preview, a binary file).
Must-dos for the dev
tar0.4 andtokio-util(io) for StreamReader/SyncIoBridge (tar parsing in spawn_blocking).When I review the PR I'll check
/of a running container with a big volume lists fast; stopped mealie/shows a partial listinstead of hanging; distroless/scratch; nonroot target; Podman; names with newline/space; symlink
abs/relative/dir; 200 MB preview doesn't load it all; helper gone after tab close and after target stops.
Helper listing script (issue13-helper-ls.sh)
Probe (issue13-probe.rs)