feat: Networks page #23

Merged
jfro merged 1 commit from feat/12-networks into main 2026-11-30 17:24:54 +00:00
Owner

Stacked on #22 (container stats): this PR targets feat/11-container-stats, so the diff shows only the Networks work. Once #22 merges I'll retarget it to main.

A Networks page in the sidebar, built on the same ResourceList / ResourceDetail pattern as Volumes and Images.

List

  • Name, driver, first subnet, "internal" flag, and how many containers are attached.
  • Sections: In Use, Unused, then Built In (bridge, host, none) at the bottom, so Docker's own networks are out of the way. Built-in ones can't be deleted (no trash button; a clear message if tried from the menu).
  • Search matches name, driver, compose project and subnet.

Details (same fields as docker network inspect)

  • Overview: name, ID, status, driver, scope, created, settings (internal, attachable, ingress, IPv6).
  • IP Addresses: each IPAM subnet with gateway and IP range (and a non-default IPAM driver).
  • Containers: attached containers with their IP on this network; click one to jump to it.
  • Compose project link, driver options and labels.

Actions: New Network (name prompt, creates a bridge network), Delete (refused client-side while containers are attached, with who's attached), Delete Unused (prune; built-ins are kept), Copy Name / ID / Subnet.

Refresh: network events join the image/volume event watch, so the page updates as networks come and go.

How: networks come from GET /networks (which returns the same IPAM/options/labels as inspect, minus containers); attached containers and their IPs come from the container list's NetworkSettings, matched by network ID. ResourceList gained optional sectionOf/sections so a page can choose its sections (Volumes and Images keep In Use / Unused).

Mock data: networks shop_default, monitoring_default, an internal backend, an attachable legacy-net, plus the built-ins; mock containers now carry endpoints with addresses. New networks screenshot scene; README features/screenshots updated (every screenshot changed because the sidebar has a new entry).

Tested

  • cargo fmt --check, clippy --all-targets -D warnings with and without mock, cargo build, cargo test (new test: networks JSON — attached containers with IPs, sorting with built-ins last, subnet/gateway, internal flag, compose project), Rust 1.100.0.
  • Against a real Docker 29.10.1 engine (dind): the list matched docker network ls; shop_default showed its 3 containers with the same IPs as docker network inspect; New Network created ui-made, Delete removed it, Delete Unused removed spare-net and kept the rest.

Screenshots (mock data)

networks

networks-light

Closes #12

**Stacked on #22** (container stats): this PR targets `feat/11-container-stats`, so the diff shows only the Networks work. Once #22 merges I'll retarget it to `main`. A Networks page in the sidebar, built on the same ResourceList / ResourceDetail pattern as Volumes and Images. **List** - Name, driver, first subnet, "internal" flag, and how many containers are attached. - Sections: In Use, Unused, then **Built In** (`bridge`, `host`, `none`) at the bottom, so Docker's own networks are out of the way. Built-in ones can't be deleted (no trash button; a clear message if tried from the menu). - Search matches name, driver, compose project and subnet. **Details** (same fields as `docker network inspect`) - Overview: name, ID, status, driver, scope, created, settings (internal, attachable, ingress, IPv6). - IP Addresses: each IPAM subnet with gateway and IP range (and a non-default IPAM driver). - Containers: attached containers with their IP on this network; click one to jump to it. - Compose project link, driver options and labels. **Actions:** New Network (name prompt, creates a bridge network), Delete (refused client-side while containers are attached, with who's attached), Delete Unused (prune; built-ins are kept), Copy Name / ID / Subnet. **Refresh:** network events join the image/volume event watch, so the page updates as networks come and go. **How:** networks come from `GET /networks` (which returns the same IPAM/options/labels as inspect, minus containers); attached containers and their IPs come from the container list's `NetworkSettings`, matched by network ID. `ResourceList` gained optional `sectionOf`/`sections` so a page can choose its sections (Volumes and Images keep In Use / Unused). **Mock data:** networks `shop_default`, `monitoring_default`, an internal `backend`, an attachable `legacy-net`, plus the built-ins; mock containers now carry endpoints with addresses. New `networks` screenshot scene; README features/screenshots updated (every screenshot changed because the sidebar has a new entry). **Tested** - `cargo fmt --check`, `clippy --all-targets -D warnings` with and without `mock`, `cargo build`, `cargo test` (new test: networks JSON — attached containers with IPs, sorting with built-ins last, subnet/gateway, internal flag, compose project), Rust 1.100.0. - Against a real Docker 29.10.1 engine (dind): the list matched `docker network ls`; shop_default showed its 3 containers with the same IPs as `docker network inspect`; New Network created `ui-made`, Delete removed it, Delete Unused removed `spare-net` and kept the rest. **Screenshots** (mock data) ![networks](https://git.knope.dev/attachments/8da6b112-6d4d-477b-bc5d-0b1874603b7b) ![networks-light](https://git.knope.dev/attachments/053b4b64-937e-4629-8e61-34e5d2106a9e) Closes #12
feat: Networks page
All checks were successful
CI / test (pull_request) Successful in 4m47s
4da39450f8
Lists every network with its driver, subnet and attached containers (with their addresses), with IPAM config, options, labels and flags in the details. Create, delete, prune unused, copy name, ID or subnet; built-in bridge/host/none are listed last and can't be deleted. Network events refresh the list like volumes and images. Mock data gets networks and container endpoints; README and screenshots updated.

Closes #12
jfro force-pushed feat/12-networks from 4da39450f8
All checks were successful
CI / test (pull_request) Successful in 4m47s
to 41a43e0e6a
All checks were successful
CI / test (pull_request) Successful in 4m40s
2026-11-30 15:55:26 +00:00
Compare
Author
Owner

Fixed F1 (from Nye) in 41a43e0, amended into the feature commit: "Delete unused networks" no longer calls Docker's prune. That prune only spares networks that have a running container, so it deleted networks used only by stopped containers, and those containers then could not start. Krane now removes, by ID, exactly the networks listed in the confirmation, and Docker still refuses any network a container joined in the meantime. The confirmation text now says networks of stopped containers are kept. I added a live-engine regression test, prune_keeps_networks_of_stopped_containers (run it with cargo test -- --ignored): it fails when the old prune runs and passes now.

Fixed F1 (from Nye) in 41a43e0, amended into the feature commit: "Delete unused networks" no longer calls Docker's prune. That prune only spares networks that have a *running* container, so it deleted networks used only by stopped containers, and those containers then could not start. Krane now removes, by ID, exactly the networks listed in the confirmation, and Docker still refuses any network a container joined in the meantime. The confirmation text now says networks of stopped containers are kept. I added a live-engine regression test, `prune_keeps_networks_of_stopped_containers` (run it with `cargo test -- --ignored`): it fails when the old prune runs and passes now.
jfro left a comment

PR #23 (#12 Networks page) review — Nye, at 4da3945

Verdict: CHANGES REQUESTED (one medium finding, F1). Everything else checks out.

Checks (C2)

  • cargo fmt --check, clippy -D warnings (with and without --features mock), tests: 11 pass.
  • --mock --show: sections In Use / Unused / Built In correct; detail shows subnet/gateway, containers with IPs,
    compose project, labels; subnet search ("172.22" -> backend) works. Volumes still section In Use / Unused.
  • Real Docker 26 + Podman 5.4 compat API: Podman's default network is also named "bridge" there, so the
    built-in check holds.

F1 (medium): prune deletes networks Krane shows as "In Use"

A network whose only containers are stopped is listed In Use (networks_json matches the stopped endpoint;
the PR's test asserts that), and confirmPrune() names only !inUse networks. But docker network prune
deletes any network with no running endpoints, so it silently removes it; the stopped container then
fails docker start ("failed to start containers"). Visible in mock: monitoring_default (prometheus stopped)
has one running user so is safe; stop grafana and Krane still shows it In Use while prune deletes it.
Proof: notes/pr23-prune-proof.sh (real Docker, scoped by a label).
Suggested fix (either):
a) Track running users separately (e.g. "activeUsers" = running containers). Prune list/dialog = networks
with no running users, non-builtin; warn by name when a listed network still has stopped containers
("db, worker (stopped) won't start until reconnected"). Keep In Use section as is.
b) Or do the prune client-side: remove only the networks Krane shows as Unused, one by one.
(a) matches Docker; (b) matches the UI. I'd take (b): what the dialog lists is exactly what goes.
Add a networks_json test for the stopped-only case either way.

Non-blocking

  • Delete is refused client-side when only stopped containers are attached; Docker itself would allow it
    (and break those containers), so refusing is the safer call. Fine as is.
  • Endpoint match falls back to the endpoint key == network name when NetworkID is empty; on Docker 26
    stopped containers keep NetworkID, so this is only for older engines. OK.
  • New connect_with_local_defaults() call sites (create/remove/prune network): add them to #16's shared-client list.

Posted by Upper Wolfjaw for Nye (Nye can't comment here).

# PR #23 (#12 Networks page) review — Nye, at 4da3945 Verdict: CHANGES REQUESTED (one medium finding, F1). Everything else checks out. ## Checks (C2) - cargo fmt --check, clippy -D warnings (with and without --features mock), tests: 11 pass. - --mock --show: sections In Use / Unused / Built In correct; detail shows subnet/gateway, containers with IPs, compose project, labels; subnet search ("172.22" -> backend) works. Volumes still section In Use / Unused. - Real Docker 26 + Podman 5.4 compat API: Podman's default network is also named "bridge" there, so the built-in check holds. ## F1 (medium): prune deletes networks Krane shows as "In Use" A network whose only containers are stopped is listed In Use (networks_json matches the stopped endpoint; the PR's test asserts that), and confirmPrune() names only !inUse networks. But `docker network prune` deletes any network with no *running* endpoints, so it silently removes it; the stopped container then fails `docker start` ("failed to start containers"). Visible in mock: monitoring_default (prometheus stopped) has one running user so is safe; stop grafana and Krane still shows it In Use while prune deletes it. Proof: notes/pr23-prune-proof.sh (real Docker, scoped by a label). Suggested fix (either): a) Track `running` users separately (e.g. "activeUsers" = running containers). Prune list/dialog = networks with no running users, non-builtin; warn by name when a listed network still has stopped containers ("db, worker (stopped) won't start until reconnected"). Keep In Use section as is. b) Or do the prune client-side: remove only the networks Krane shows as Unused, one by one. (a) matches Docker; (b) matches the UI. I'd take (b): what the dialog lists is exactly what goes. Add a networks_json test for the stopped-only case either way. ## Non-blocking - Delete is refused client-side when only stopped containers are attached; Docker itself would allow it (and break those containers), so refusing is the safer call. Fine as is. - Endpoint match falls back to the endpoint key == network name when NetworkID is empty; on Docker 26 stopped containers keep NetworkID, so this is only for older engines. OK. - New connect_with_local_defaults() call sites (create/remove/prune network): add them to #16's shared-client list. _Posted by Upper Wolfjaw for Nye (Nye can't comment here)._
jfro force-pushed feat/12-networks from 41a43e0e6a
All checks were successful
CI / test (pull_request) Successful in 4m40s
to e40fcdbd63
All checks were successful
CI / test (pull_request) Successful in 5m36s
CI / test (push) Successful in 5m16s
2026-11-30 16:31:28 +00:00
Compare
Author
Owner

Fixed F2 in e40fcdb (amended into the feature commit): the opt-in test prune_keeps_networks_of_stopped_containers now creates an unused krane-test-prune-unused network, passes only krane-test-* networks to prune_networks, and checks that one is deleted while the stopped container's network stays. A canary network outside the test survives cargo test -- --ignored. #24 and #25 rebased on top.

Fixed F2 in e40fcdb (amended into the feature commit): the opt-in test `prune_keeps_networks_of_stopped_containers` now creates an unused `krane-test-prune-unused` network, passes only `krane-test-*` networks to `prune_networks`, and checks that one is deleted while the stopped container's network stays. A canary network outside the test survives `cargo test -- --ignored`. #24 and #25 rebased on top.
jfro changed target branch from feat/11-container-stats to main 2026-11-30 17:00:03 +00:00
jfro merged commit e40fcdbd63 into main 2026-11-30 17:24:54 +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!23
No description provided.