diff --git a/deploy/dind-evaluation/README.md b/deploy/dind-evaluation/README.md new file mode 100644 index 0000000..7cafe46 --- /dev/null +++ b/deploy/dind-evaluation/README.md @@ -0,0 +1,71 @@ +# Docker-in-Kubernetes evaluation + +This directory holds a shared test suite and per-candidate results for +comparing ways to run Docker inside Kubernetes workspaces: Envbox, direct +Sysbox, native user namespaces, rootless Podman, Kata Containers, KubeVirt, +and others. + +Every candidate runs the same suite, so results can be compared side by side. +This work re-tests the August 2026 spikes in +[`plat-370-experiments`](https://github.com/coder/envbox/tree/george/plat-370-eks-dind-experiment/deploy/plat-370-experiments) +on current versions and adds candidates that were not tested then. + +## Running the suite + +Run the suite from inside a workspace that uses the candidate runtime: + +```sh +./run-suite.sh -o results/- +``` + +| Flag | Meaning | +|---|---| +| `-o DIR` | Where to write results. Defaults to `./results/-`. | +| `-l N` | Highest use-case level to run, from 1 to 3. Defaults to 3. | +| `-k` | Also create a kind cluster in level 3. This is slow and pulls a large image. | +| `-c` | Keep running later levels after a level fails, to see everything that works. | + +| Variable | Meaning | +|---|---| +| `ENGINE` | Container CLI to test. Defaults to `docker`. `podman` also works. | +| `ALPINE_IMAGE`, `NGINX_IMAGE` | Test images. Point them at a mirror for air-gapped clusters. | + +The script needs `bash`, `curl`, and `python3`. It exits non-zero if any check +fails. + +## What it checks + +Use cases run in order. A level runs only if every earlier level passed, +unless `-c` is set. + +| Level | Use case | Checks | +|---|---|---| +| 1 | Docker commands | Engine reachable, pull, run, outbound network, detached container, exec, published port, named volume persistence, memory and CPU limits enforced in the container's cgroup, nested container has its own network namespace | +| 2 | Image builds | Single-stage build, multi-stage build, run the built image, Buildx available | +| 3 | Compose and nested tools | Compose with service-name networking, kind cluster (with `-k`) | + +## Output + +Each run writes two files: + +- `results.jsonl`: one line per check with the level, check name, `pass` or + `fail`, duration in seconds, and the last lines of output for failures. +- `security-shape.txt`: what the workspace looks like from inside: + - user ID and capabilities; + - seccomp status; + - user namespace mapping; + - cgroup mode; + - which devices exist (`/dev/kvm`, `/dev/fuse`, `/dev/net/tun`, + `/dev/kmsg`); + - engine version and security options. + +The suite can't see the node side of the security shape: privileged pods, +node runtime installs, cluster operators, and instance-type requirements. Each +candidate's `findings.md` must record those by hand. + +## Results + +| Candidate | Cluster | Levels passed | Findings | +|---|---|---|---| +| Kata Containers | dogfood EKS (`coder-kata`) | 1 to 3, 17 of 17 (kind needs a `/dev/kmsg` workaround) | [findings](results/kata-dogfood-eks/findings.md) | +| Rootless Podman | dogfood EKS (`podman-rootless`) | 2 only. 12 of 17: no limits, no network isolation, no Compose or kind | [findings](results/podman-rootless-dogfood-eks/findings.md) | diff --git a/deploy/dind-evaluation/results/kata-dogfood-eks/findings.md b/deploy/dind-evaluation/results/kata-dogfood-eks/findings.md new file mode 100644 index 0000000..177163e --- /dev/null +++ b/deploy/dind-evaluation/results/kata-dogfood-eks/findings.md @@ -0,0 +1,79 @@ +# Kata Containers on dogfood EKS + +- **Run date:** 2026-12-04 +- **Workspace:** dogfood `coder-kata` template (Kata VM on the dogfood-cdr EKS + cluster) +- **Command:** `./run-suite.sh -k -o results/kata-dogfood-eks` +- **Raw output:** [`results.jsonl`](results.jsonl), + [`security-shape.txt`](security-shape.txt) + +## Result + +All 17 checks passed, covering use-case levels 1 to 3, including creating a +kind cluster. Memory and CPU limits are enforced in each nested container's +cgroup, and every nested container gets its own network namespace. + +| Level | Checks | Slowest check | +|---|---|---| +| 1. Docker commands | 11 of 11 passed | named volume, 1.2 s | +| 2. Image builds | 4 of 4 passed | about 0.5 s each | +| 3. Compose and kind | 2 of 2 passed | kind cluster: 31.3 s | + +These durations are for operations inside an already-running workspace. They +are **not** workspace startup time, which still needs measuring (see "Not +measured yet"). + +## Security shape (inside the workspace) + +From [`security-shape.txt`](security-shape.txt): + +- The workspace user is uid 1000 and has no effective capabilities, but has + passwordless `sudo` to root with full capabilities. This is inside the VM + guest, so the VM stays the boundary. +- `dockerd` runs as root, with full capabilities, inside the Kata VM guest. + The isolation boundary is the VM, not the container. +- No user namespace is used inside the guest (identity mapping). +- No seccomp filter on the workspace process. +- cgroup v2 is read-only for the workspace user. +- No `/dev/kvm`, `/dev/fuse`, `/dev/net/tun`, or `/dev/kmsg` in the guest. +- Docker Engine 27.5.1, containerd 1.7.23, runc 1.1.14, overlay2 storage. + +## Workarounds needed + +- **kind needs `/dev/kmsg`.** The guest has no `/dev/kmsg`, so kubelet exits + with `open /dev/kmsg: no such file or directory`. Mounting `/dev/null` at + `/dev/kmsg` in the kind node fixes it. The suite applies this + automatically and records the check as `kind-create-cluster-kmsg-workaround`. + +## Node side (not visible from inside, still to confirm) + +TODO: confirm with the dogfood infra team. + +- Which instance types the Kata node group uses: bare metal or + nested-virtualization capable. +- How the Kata runtime is installed on the nodes (for example kata-deploy + DaemonSet, custom AMI) and the `RuntimeClass` it registers. +- Whether the workspace pod itself is privileged or needs Pod Security + exceptions. +- Kata and guest kernel versions. + +## Related dogfood history + +[DOG-65](https://linear.app/codercom/issue/DOG-65/scale-dogfood-horizontally-by-moving-templates-to-kubernetes) +moved dogfood development to `coder-kata`. It records: + +- a cgroup and Postgres failure that has since been fixed, with Docker memory + limits kept; +- prebuilds that work across clusters; +- an open question on whether network policies work inside Kata, for + `coder-workflow-bot`. + +## Not measured yet + +- Workspace startup time (create to agent Ready) as p50 and p95, compared + with a plain pod workspace on the same cluster. +- GKE. +- Air-gapped installation. +- Nested virtualization inside the guest. There is no `/dev/kvm`, even though + the CPU advertises `vmx`, so KubeVirt and Firecracker can't run nested + inside a Kata workspace as configured. diff --git a/deploy/dind-evaluation/results/kata-dogfood-eks/results.jsonl b/deploy/dind-evaluation/results/kata-dogfood-eks/results.jsonl new file mode 100644 index 0000000..ed9bbf0 --- /dev/null +++ b/deploy/dind-evaluation/results/kata-dogfood-eks/results.jsonl @@ -0,0 +1,17 @@ +{"level":1,"check":"engine-reachable","status":"pass","seconds":0.14,"detail":""} +{"level":1,"check":"pull-image","status":"pass","seconds":0.49,"detail":""} +{"level":1,"check":"run-container","status":"pass","seconds":0.58,"detail":""} +{"level":1,"check":"outbound-network","status":"pass","seconds":0.56,"detail":""} +{"level":1,"check":"run-detached","status":"pass","seconds":0.44,"detail":""} +{"level":1,"check":"exec-into-container","status":"pass","seconds":0.12,"detail":""} +{"level":1,"check":"published-port","status":"pass","seconds":0.10,"detail":""} +{"level":1,"check":"named-volume-persists","status":"pass","seconds":1.15,"detail":""} +{"level":1,"check":"memory-limit-enforced","status":"pass","seconds":0.59,"detail":""} +{"level":1,"check":"cpu-limit-enforced","status":"pass","seconds":0.55,"detail":""} +{"level":1,"check":"network-namespace-isolated","status":"pass","seconds":0.57,"detail":""} +{"level":2,"check":"build-image","status":"pass","seconds":0.48,"detail":""} +{"level":2,"check":"multi-stage-build","status":"pass","seconds":0.44,"detail":""} +{"level":2,"check":"run-built-image","status":"pass","seconds":0.54,"detail":""} +{"level":2,"check":"buildx-available","status":"pass","seconds":0.19,"detail":""} +{"level":3,"check":"compose-service-networking","status":"pass","seconds":1.65,"detail":""} +{"level":3,"check":"kind-create-cluster-kmsg-workaround","status":"pass","seconds":31.25,"detail":""} diff --git a/deploy/dind-evaluation/results/kata-dogfood-eks/security-shape.txt b/deploy/dind-evaluation/results/kata-dogfood-eks/security-shape.txt new file mode 100644 index 0000000..bfa777d --- /dev/null +++ b/deploy/dind-evaluation/results/kata-dogfood-eks/security-shape.txt @@ -0,0 +1,63 @@ +## identity +uid=1000 gid=1000 user=coder +passwordless sudo: yes +root capabilities via sudo: CapEff: 000001ffffffffff +## process status +CapInh: 0000000000000000 +CapPrm: 0000000000000000 +CapEff: 0000000000000000 +CapBnd: 000001ffffffffff +CapAmb: 0000000000000000 +NoNewPrivs: 0 +Seccomp: 0 +Seccomp_filters: 0 +## user namespace (identity map means none) + 0 0 4294967295 +## kernel and virtualization +Linux 6.18.35 x86_64 +docker +## cgroups +cgroupfs type: cgroup2fs +/sys/fs/cgroup read-only +## devices +/dev/kvm absent +/dev/fuse absent +/dev/net/tun absent +/dev/kmsg absent +## engine +Client: Docker Engine - Community + Version: 27.5.1 + API version: 1.47 + Go version: go1.22.11 + Git commit: 9f9e405 + Built: Wed Jan 22 13:41:31 2025 + OS/Arch: linux/amd64 + Context: default + +Server: Docker Engine - Community + Engine: + Version: 27.5.1 + API version: 1.47 (minimum version 1.24) + Go version: go1.22.11 + Git commit: 4c9b3b0 + Built: Wed Jan 22 13:41:31 2025 + OS/Arch: linux/amd64 + Experimental: false + containerd: + Version: 1.7.23 + GitCommit: 57f17b0a6295a39009d861b89e3b3b87b005ca27 + runc: + Version: 1.1.14 + GitCommit: v1.1.14-0-g2c9f560 + docker-init: + Version: 0.19.0 + GitCommit: de40ad0 + Server Version: 27.5.1 + Storage Driver: overlay2 + Cgroup Driver: cgroupfs + Cgroup Version: 2 + Runtimes: runc io.containerd.runc.v2 + Default Runtime: runc + Security Options: + seccomp + cgroupns diff --git a/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/docker-cli/results.jsonl b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/docker-cli/results.jsonl new file mode 100644 index 0000000..3203fbb --- /dev/null +++ b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/docker-cli/results.jsonl @@ -0,0 +1,17 @@ +{"level":1,"check":"engine-reachable","status":"pass","seconds":0.10,"detail":""} +{"level":1,"check":"pull-image","status":"pass","seconds":2.52,"detail":""} +{"level":1,"check":"run-container","status":"pass","seconds":0.12,"detail":""} +{"level":1,"check":"outbound-network","status":"pass","seconds":0.36,"detail":""} +{"level":1,"check":"run-detached","status":"pass","seconds":0.08,"detail":""} +{"level":1,"check":"exec-into-container","status":"pass","seconds":0.07,"detail":""} +{"level":1,"check":"published-port","status":"pass","seconds":0.02,"detail":""} +{"level":1,"check":"named-volume-persists","status":"pass","seconds":0.25,"detail":""} +{"level":1,"check":"memory-limit-enforced","status":"fail","seconds":0.12,"detail":"memory limit seen in container: 8589934592 (want 33554432)"} +{"level":1,"check":"cpu-limit-enforced","status":"fail","seconds":0.12,"detail":"cpu limit seen in container: 400000 100000 (want a 50% quota)"} +{"level":1,"check":"network-namespace-isolated","status":"fail","seconds":0.12,"detail":"workspace netns net:[4026533416], container netns net:[4026533416]"} +{"level":2,"check":"build-image","status":"pass","seconds":0.29,"detail":""} +{"level":2,"check":"multi-stage-build","status":"pass","seconds":4.57,"detail":""} +{"level":2,"check":"run-built-image","status":"pass","seconds":0.13,"detail":""} +{"level":2,"check":"buildx-available","status":"pass","seconds":0.04,"detail":""} +{"level":3,"check":"compose-service-networking","status":"fail","seconds":0.24,"detail":"Attaching to client-1, web-1\n Container dindeval-2653-26257-web-1 Starting \n Container dindeval-2653-26257-web-1 Error response from daemon: setting up Pasta: could not find pasta, the network namespace can't be configured: exec: \"pasta\": executable file not found in $PATH \n Container dindeval-2653-26257-client-1 not started: interrupted by the failure of Container dindeval-2653-26257-web-1 \nError response from daemon: setting up Pasta: could not find pasta, the network namespace can't be configured: exec: \"pasta\": executable file not found in $PATH"} +{"level":3,"check":"kind-create-cluster-kmsg-workaround","status":"fail","seconds":0.11,"detail":"ERROR: failed to create cluster: running kind with rootless provider requires setting systemd property \"Delegate=yes\", see https://kind.sigs.k8s.io/docs/user/rootless/"} diff --git a/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/docker-cli/security-shape.txt b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/docker-cli/security-shape.txt new file mode 100644 index 0000000..b83cecc --- /dev/null +++ b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/docker-cli/security-shape.txt @@ -0,0 +1,75 @@ +## identity +uid=1000 gid=1000 user=coder +passwordless sudo: yes +root capabilities via sudo: CapEff: 00000000a80425fb +## process status +CapInh: 0000000000000000 +CapPrm: 0000000000000000 +CapEff: 0000000000000000 +CapBnd: 00000000a80425fb +CapAmb: 0000000000000000 +NoNewPrivs: 0 +Seccomp: 0 +Seccomp_filters: 0 +## user namespace (identity map means none) + 0 0 4294967295 +## kernel and virtualization +Linux 6.18.56-125.164.amzn2023.x86_64 x86_64 +docker +## cgroups +cgroupfs type: cgroup2fs +/sys/fs/cgroup read-only +## devices +/dev/kvm absent +/dev/fuse absent +/dev/net/tun absent +/dev/kmsg absent +## engine +Client: Docker Engine - Community + Version: 29.9.3 + API version: 1.41 (downgraded from 1.56) + Go version: go1.26.10 + Git commit: 5457199 + Built: Tue Nov 3 21:42:07 2026 + OS/Arch: linux/amd64 + Context: default + +Server: linux/amd64/ubuntu-26.04 + Podman Engine: + Version: 5.7.0 + APIVersion: 5.7.0 + Arch: amd64 + BuildTime: 2026-02-23T15:35:32Z + Experimental: false + GitCommit: + GoVersion: go1.25.0 + KernelVersion: 6.18.56-125.164.amzn2023.x86_64 + MinAPIVersion: 4.0.0 + Os: linux + Conmon: + Version: conmon version 2.1.13, commit: unknown + Package: conmon_2.1.13+ds1-2_amd64 + OCI Runtime (crun): + Version: crun version 1.21 +commit: 10269840aa07fb7e6b7e1acff6198692d8ff5c88 +rundir: /tmp/storage-run-1000/crun +spec: 1.0.0 ++SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +WASM:wasmedge +YAJL + Package: crun_1.21-1ubuntu3_amd64 + Engine: + Version: 5.7.0 + API version: 1.41 (minimum version 1.24) + Go version: + Git commit: + Built: + OS/Arch: linux/amd64 + Experimental: + Server Version: 5.7.0 + Storage Driver: overlay + Cgroup Driver: cgroupfs + Cgroup Version: 2 + Runtimes: runc runj runsc youki crun crun-vm crun-wasm kata krun ocijail + Default Runtime: crun + Security Options: + seccomp + rootless diff --git a/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/findings.md b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/findings.md new file mode 100644 index 0000000..7696b97 --- /dev/null +++ b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/findings.md @@ -0,0 +1,95 @@ +# Rootless Podman on dogfood EKS + +- **Run date:** 2026-12-04 +- **Workspace:** dogfood `podman-rootless` template, described as "Rootless + Podman on EKS (Bangkok) without privileged pods". Default 50 GB disk. +- **Node kernel:** `6.18.56-125.164.amzn2023` (AL2023 EKS node) +- **Engine:** Podman 5.7.0 with crun 1.21. Docker CLI 29.9.3 and Docker + Compose v5.7.0 talk to Podman through its Docker-compatible API. +- **Commands:** + - `ENGINE=docker ./run-suite.sh -k -c -o results/podman-rootless-docker-cli` + - `ENGINE=podman ./run-suite.sh -k -c -o results/podman-rootless-podman-cli` + + `-c` runs every level even after a failure, so builds and Compose were + still tested. kind was installed into `~/bin` for the run. +- **Raw output:** [`docker-cli/`](docker-cli/), [`podman-cli/`](podman-cli/) + +## Result + +The Docker CLI and the Podman CLI give the same results: 12 of 17 checks +pass with the Docker CLI, and 11 of 16 with the Podman CLI (Buildx is +Docker-only). + +| Level | Passed | Failed | +|---|---|---| +| 1. Docker commands | engine reachable, pull, run, outbound network, detached container, exec, published port, named volume | **memory limit, CPU limit, network isolation** | +| 2. Image builds | build, multi-stage build, run built image, Buildx | none | +| 3. Compose and kind | none | **Compose networking, kind** | + +Containers run and images build. The failures come from the template +running Podman with isolation features turned off, because the pod lacks +what those features need. + +## Root causes + +The template's `/etc/containers/containers.conf` sets `netns="host"`, +`userns="host"`, `cgroupns="host"`, and `cgroups="disabled"`. That's the +usual setup for Podman inside an unprivileged container. It exists because +of two limits of the pod: + +1. **No `/dev/net/tun`.** Rootless Podman's network tools (`pasta`, + `slirp4netns`) need it to give each container its own network. + `podman run --network slirp4netns` fails with + `open("/dev/net/tun"): No such file or directory`, and `pasta` isn't + installed. As a result: + - Nested containers share the workspace's network namespace (the same + `net:[...]` ID). They have no network isolation from each other or + from the workspace, and two containers can't listen on the same port. + - "Published ports" pass only because the container already listens on + the workspace's own network. + - Compose fails because it can't create its project network + (`setting up Pasta: could not find pasta`). +2. **No cgroup delegation.** `/sys/fs/cgroup` is read-only and no + controllers are delegated to the pod. As a result: + - **Resource limits are silently ignored.** A container started with + `--memory 32m` sees the pod's 8 GiB limit and allocated 200 MB without + being killed. `--cpus 0.5` shows the pod's 4-CPU quota. + - kind fails: rootless kind needs systemd cgroup delegation + (`Delegate=yes`). + +Fixing either one needs a change outside the workspace: + +- a device plugin or similar to expose `/dev/net/tun` (and `/dev/fuse`, if + storage needs it); +- cgroup delegation or a writable cgroup namespace for the pod. + +Both are node-level or cluster-level changes, which moves a fully working +rootless Podman from Tier D (locked down) to Tier B (node access). + +## Security shape + +From [`docker-cli/security-shape.txt`](docker-cli/security-shape.txt): + +- The pod is not privileged. Its capability bounding set is the + container-runtime default (`a80425fb`). +- The workspace user is uid 1000 with no effective capabilities, but **has + passwordless `sudo`** to root, which then has the default capability set. +- **No seccomp filter** on the workspace process (the pod runs + `Unconfined`). +- No user namespace for the pod itself. Rootless Podman creates its own user + namespace for containers (subuid range `100000:65536`). +- No `/dev/kvm`, `/dev/fuse`, `/dev/net/tun`, or `/dev/kmsg`. Overlay storage + works without `/dev/fuse`, using the kernel's unprivileged overlayfs. + +TODO: confirm the pod spec with the template owner (security context, +seccomp profile, AppArmor, Pod Security level of the namespace). + +## Not measured yet + +- Workspace startup time (create to agent Ready). The template build took + 24 s to apply on first create, but agent readiness wasn't timed. +- Whether installing `pasta` alone is enough. This is likely not the case, + because `pasta` also needs `/dev/net/tun`. +- A variant with `/dev/net/tun` and cgroup delegation on a node pool we can + change (Tier B). +- Devcontainers, GKE, air-gapped. diff --git a/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/podman-cli/results.jsonl b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/podman-cli/results.jsonl new file mode 100644 index 0000000..d218986 --- /dev/null +++ b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/podman-cli/results.jsonl @@ -0,0 +1,16 @@ +{"level":1,"check":"engine-reachable","status":"pass","seconds":0.10,"detail":""} +{"level":1,"check":"pull-image","status":"pass","seconds":2.46,"detail":""} +{"level":1,"check":"run-container","status":"pass","seconds":0.12,"detail":""} +{"level":1,"check":"outbound-network","status":"pass","seconds":0.38,"detail":""} +{"level":1,"check":"run-detached","status":"pass","seconds":0.10,"detail":""} +{"level":1,"check":"exec-into-container","status":"pass","seconds":0.14,"detail":""} +{"level":1,"check":"published-port","status":"pass","seconds":0.05,"detail":""} +{"level":1,"check":"named-volume-persists","status":"pass","seconds":0.26,"detail":""} +{"level":1,"check":"memory-limit-enforced","status":"fail","seconds":0.12,"detail":"memory limit seen in container: 8589934592 (want 33554432)"} +{"level":1,"check":"cpu-limit-enforced","status":"fail","seconds":0.13,"detail":"cpu limit seen in container: 400000 100000 (want a 50% quota)"} +{"level":1,"check":"network-namespace-isolated","status":"fail","seconds":0.13,"detail":"workspace netns net:[4026533416], container netns net:[4026533416]"} +{"level":2,"check":"build-image","status":"pass","seconds":0.31,"detail":""} +{"level":2,"check":"multi-stage-build","status":"pass","seconds":4.74,"detail":""} +{"level":2,"check":"run-built-image","status":"pass","seconds":0.13,"detail":""} +{"level":3,"check":"compose-service-networking","status":"fail","seconds":0.23,"detail":"Container dindeval-3919-8584-web-1 Starting \n Container dindeval-3919-8584-web-1 Error response from daemon: setting up Pasta: could not find pasta, the network namespace can't be configured: exec: \"pasta\": executable file not found in $PATH \n Container dindeval-3919-8584-client-1 not started: interrupted by the failure of Container dindeval-3919-8584-web-1 \nError response from daemon: setting up Pasta: could not find pasta, the network namespace can't be configured: exec: \"pasta\": executable file not found in $PATH\nError: executing /usr/libexec/docker/cli-plugins/docker-compose -p dindeval-3919-8584 up --abort-on-container-exit --exit-code-from client: exit status 1"} +{"level":3,"check":"kind-create-cluster-kmsg-workaround","status":"fail","seconds":0.12,"detail":"ERROR: failed to create cluster: running kind with rootless provider requires setting systemd property \"Delegate=yes\", see https://kind.sigs.k8s.io/docs/user/rootless/"} diff --git a/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/podman-cli/security-shape.txt b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/podman-cli/security-shape.txt new file mode 100644 index 0000000..e5d09cc --- /dev/null +++ b/deploy/dind-evaluation/results/podman-rootless-dogfood-eks/podman-cli/security-shape.txt @@ -0,0 +1,45 @@ +## identity +uid=1000 gid=1000 user=coder +passwordless sudo: yes +root capabilities via sudo: CapEff: 00000000a80425fb +## process status +CapInh: 0000000000000000 +CapPrm: 0000000000000000 +CapEff: 0000000000000000 +CapBnd: 00000000a80425fb +CapAmb: 0000000000000000 +NoNewPrivs: 0 +Seccomp: 0 +Seccomp_filters: 0 +## user namespace (identity map means none) + 0 0 4294967295 +## kernel and virtualization +Linux 6.18.56-125.164.amzn2023.x86_64 x86_64 +docker +## cgroups +cgroupfs type: cgroup2fs +/sys/fs/cgroup read-only +## devices +/dev/kvm absent +/dev/fuse absent +/dev/net/tun absent +/dev/kmsg absent +## engine +Client: Podman Engine +Version: 5.7.0 +API Version: 5.7.0 +Go Version: go1.25.0 +Built: Mon Feb 23 15:35:32 2026 +Build Origin: Ubuntu +OS/Arch: linux/amd64 + cgroupControllers: + cgroupManager: cgroupfs + cgroupVersion: v2 + ociRuntime: + +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +WASM:wasmedge +YAJL + rootlessNetworkCmd: pasta + security: + rootless: true + seccompEnabled: true + seccompProfilePath: /usr/share/containers/seccomp.json + libseccomp: 2.6.0 diff --git a/deploy/dind-evaluation/run-suite.sh b/deploy/dind-evaluation/run-suite.sh new file mode 100755 index 0000000..851df7d --- /dev/null +++ b/deploy/dind-evaluation/run-suite.sh @@ -0,0 +1,252 @@ +#!/usr/bin/env bash +# Runs the Docker-in-workspace evaluation suite from inside a workspace and +# records the result of each check, its duration, and the security shape of +# the environment. Every candidate runtime (Envbox, Sysbox, Kata, KubeVirt, +# rootless Podman, and so on) runs the same suite so results are comparable. +# +# Usage: run-suite.sh [-o OUTPUT_DIR] [-l MAX_LEVEL] [-k] [-c] +# -o directory for results (default: ./results/-) +# -l highest use-case level to run, 1 to 3 (default: 3) +# -k also create a kind cluster in level 3 (slow, pulls a large image) +# -c keep running later levels after a level fails +# +# Environment: +# ENGINE container CLI to test (default: docker; podman also works) +# ALPINE_IMAGE image for small checks (default: alpine:3.20) +# NGINX_IMAGE image for network checks (default: nginx:1.27-alpine) +# Point the image variables at a mirror to run in an air-gapped cluster. + +set -uo pipefail + +ENGINE="${ENGINE:-docker}" +ALPINE_IMAGE="${ALPINE_IMAGE:-alpine:3.20}" +NGINX_IMAGE="${NGINX_IMAGE:-nginx:1.27-alpine}" +MAX_LEVEL=3 +RUN_KIND=0 +CONTINUE=0 +OUT="" + +while getopts "o:l:kch" opt; do + case "$opt" in + o) OUT="$OPTARG" ;; + l) MAX_LEVEL="$OPTARG" ;; + k) RUN_KIND=1 ;; + c) CONTINUE=1 ;; + *) + sed -n '2,18p' "$0" + exit 2 + ;; + esac +done + +OUT="${OUT:-./results/$(hostname)-$(date -u +%Y%m%dT%H%M%SZ)}" +mkdir -p "$OUT" +RESULTS="$OUT/results.jsonl" +: >"$RESULTS" + +# Unique names so concurrent runs on one daemon don't collide. +ID="dindeval-$$-$RANDOM" +WORK="$(mktemp -d)" +FAILED_LEVELS=() + +cleanup() { + "$ENGINE" rm -f "$ID-web" "$ID-vol" >/dev/null 2>&1 + "$ENGINE" volume rm -f "$ID-data" >/dev/null 2>&1 + "$ENGINE" rmi -f "$ID-build:1" "$ID-multi:1" >/dev/null 2>&1 + if [ -f "$WORK/compose.yaml" ]; then + (cd "$WORK" && "$ENGINE" compose -p "$ID" down -v >/dev/null 2>&1) + fi + if [ "$RUN_KIND" = 1 ] && command -v kind >/dev/null; then + kind delete cluster --name "$ID" >/dev/null 2>&1 + fi + rm -rf "$WORK" +} +trap cleanup EXIT + +# Monotonic milliseconds from /proc/uptime (10 ms resolution). Wall-clock time +# can step backwards when the clock is adjusted mid-run. +now_ms() { awk '{ printf "%d", $1 * 1000 }' /proc/uptime; } + +json_escape() { + python3 -I -c 'import json,sys; print(json.dumps(sys.stdin.read().strip()))' +} + +# check LEVEL NAME COMMAND...: runs COMMAND, records pass or fail and the +# duration, and keeps the last lines of output for failures. +check() { + local level="$1" name="$2" + shift 2 + local start end status secs detail + start="$(now_ms)" + if detail="$("$@" 2>&1)"; then status=pass; else status=fail; fi + end="$(now_ms)" + secs="$(awk -v s="$start" -v e="$end" 'BEGIN { printf "%.2f", (e - s) / 1000 }')" + if [ "$status" = fail ]; then + FAILED_LEVELS+=("$level") + else + detail="" + fi + printf '{"level":%s,"check":"%s","status":"%s","seconds":%s,"detail":%s}\n' \ + "$level" "$name" "$status" "$secs" "$(printf '%s' "$detail" | tail -n 5 | json_escape)" >>"$RESULTS" + printf ' %-4s %7ss %s\n' "$status" "$secs" "$name" +} + +level_failed() { + local l + [ "$CONTINUE" = 1 ] && return 1 + for l in "${FAILED_LEVELS[@]:-}"; do + [ "$l" = "$1" ] && return 0 + done + return 1 +} + +# The security shape is recorded as seen from inside the workspace. The node +# side (privileged pods, runtime installs, operators) must be written up +# separately in the findings because it is not visible from here. +record_security_shape() { + local f="$OUT/security-shape.txt" + { + echo "## identity" + echo "uid=$(id -u) gid=$(id -g) user=$(id -un)" + if sudo -n true 2>/dev/null; then + echo "passwordless sudo: yes" + echo "root capabilities via sudo: $(sudo -n grep CapEff /proc/self/status)" + else + echo "passwordless sudo: no" + fi + echo "## process status" + grep -E '^(CapInh|CapPrm|CapEff|CapBnd|CapAmb|NoNewPrivs|Seccomp|Seccomp_filters):' /proc/self/status + echo "## user namespace (identity map means none)" + cat /proc/self/uid_map + echo "## kernel and virtualization" + uname -srm + systemd-detect-virt 2>/dev/null || echo "systemd-detect-virt: unavailable" + echo "## cgroups" + stat -fc 'cgroupfs type: %T' /sys/fs/cgroup + if [ -w /sys/fs/cgroup ]; then echo "/sys/fs/cgroup writable"; else echo "/sys/fs/cgroup read-only"; fi + echo "## devices" + for d in /dev/kvm /dev/fuse /dev/net/tun /dev/kmsg; do + if [ -e "$d" ]; then echo "$d present"; else echo "$d absent"; fi + done + echo "## engine" + "$ENGINE" version 2>&1 | sed -n '1,40p' + "$ENGINE" info 2>&1 | grep -iE 'rootless|security|seccomp|cgroup|runtime|storage driver|userns|server version' + } >"$f" 2>&1 +} + +echo "Results: $OUT" +echo "Engine: $ENGINE" +record_security_shape + +# Level 1: docker commands at runtime. +echo "Level 1: docker commands" +check 1 engine-reachable "$ENGINE" info +check 1 pull-image "$ENGINE" pull -q "$ALPINE_IMAGE" +check 1 run-container "$ENGINE" run --rm "$ALPINE_IMAGE" true +check 1 outbound-network "$ENGINE" run --rm "$ALPINE_IMAGE" wget -q -O /dev/null -T 10 http://example.com +check 1 run-detached "$ENGINE" run -d --name "$ID-web" -p 127.0.0.1::80 "$NGINX_IMAGE" +check 1 exec-into-container "$ENGINE" exec "$ID-web" nginx -v +publish_reachable() { + local port + port="$("$ENGINE" port "$ID-web" 80/tcp | head -n1 | sed 's/.*://')" + for _ in $(seq 1 20); do + curl -sf -o /dev/null "http://127.0.0.1:$port" && return 0 + sleep 0.5 + done + return 1 +} +check 1 published-port "publish_reachable" +volume_persists() { + "$ENGINE" run --rm -v "$ID-data:/data" "$ALPINE_IMAGE" sh -c 'echo ok > /data/f' && + "$ENGINE" run --rm -v "$ID-data:/data" "$ALPINE_IMAGE" grep -q ok /data/f +} +check 1 named-volume-persists "volume_persists" +# Accepting the flags is not enough: some setups (for example Podman with +# cgroups disabled) ignore them. Check the limit is applied in the container's +# own cgroup. +memory_limit_enforced() { + local got + got="$("$ENGINE" run --rm --memory 32m "$ALPINE_IMAGE" sh -c \ + 'cat /sys/fs/cgroup/memory.max 2>/dev/null || cat /sys/fs/cgroup/memory/memory.limit_in_bytes')" + echo "memory limit seen in container: $got (want 33554432)" + [ "$got" = 33554432 ] +} +check 1 memory-limit-enforced "memory_limit_enforced" +cpu_limit_enforced() { + local got + got="$("$ENGINE" run --rm --cpus 0.5 "$ALPINE_IMAGE" sh -c \ + 'cat /sys/fs/cgroup/cpu.max 2>/dev/null || cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us')" + echo "cpu limit seen in container: $got (want a 50% quota)" + case "$got" in + "50000 100000" | 50000) return 0 ;; + *) return 1 ;; + esac +} +check 1 cpu-limit-enforced "cpu_limit_enforced" +# A nested container that shares the workspace network namespace has no +# network isolation, and published ports are not really being published. +network_isolated() { + local ws inner + ws="$(readlink /proc/self/ns/net)" + inner="$("$ENGINE" run --rm "$ALPINE_IMAGE" readlink /proc/self/ns/net)" + echo "workspace netns $ws, container netns $inner" + [ -n "$inner" ] && [ "$ws" != "$inner" ] +} +check 1 network-namespace-isolated "network_isolated" + +if [ "$MAX_LEVEL" -ge 2 ] && ! level_failed 1; then + echo "Level 2: image builds" + printf 'FROM %s\nRUN echo built > /built\n' "$ALPINE_IMAGE" >"$WORK/Dockerfile" + check 2 build-image "$ENGINE" build -q -t "$ID-build:1" "$WORK" + printf 'FROM %s AS a\nRUN echo stage > /s\nFROM %s\nCOPY --from=a /s /s\n' "$ALPINE_IMAGE" "$ALPINE_IMAGE" >"$WORK/Dockerfile.multi" + check 2 multi-stage-build "$ENGINE" build -q -f "$WORK/Dockerfile.multi" -t "$ID-multi:1" "$WORK" + check 2 run-built-image "$ENGINE" run --rm "$ID-multi:1" cat /s + if [ "$ENGINE" = docker ]; then + check 2 buildx-available docker buildx version + fi +fi + +if [ "$MAX_LEVEL" -ge 3 ] && ! level_failed 1 && ! level_failed 2; then + echo "Level 3: Compose and nested tools" + cat >"$WORK/compose.yaml" </dev/null; then + # kubelet exits if /dev/kmsg is missing, which happens when the + # workspace itself has none. Mounting /dev/null in its place is the + # usual workaround; the check name records that it was needed. + local_kind_check=kind-create-cluster + printf 'kind: Cluster\napiVersion: kind.x-k8s.io/v1alpha4\n' >"$WORK/kind.yaml" + if [ ! -e /dev/kmsg ]; then + local_kind_check=kind-create-cluster-kmsg-workaround + printf 'nodes:\n - role: control-plane\n extraMounts:\n - hostPath: /dev/null\n containerPath: /dev/kmsg\n' >>"$WORK/kind.yaml" + fi + check 3 "$local_kind_check" kind create cluster --name "$ID" --config "$WORK/kind.yaml" --wait 120s + else + echo " skip kind not on PATH" + fi + fi +fi + +python3 -I - "$RESULTS" <<'EOF' +import json, sys +rows = [json.loads(l) for l in open(sys.argv[1])] +passed = sum(r["status"] == "pass" for r in rows) +print(f"\n{passed}/{len(rows)} checks passed") +for r in rows: + if r["status"] == "fail": + print(f" FAILED level {r['level']} {r['check']}: {r['detail']}") +EOF + +[ "${#FAILED_LEVELS[@]}" -eq 0 ]