docker build, which expects a Docker daemon listening on a Unix socket. K7 ships a generic sidecar framework that injects a daemon container into the sandbox pod and shares a socket with the main container — all inside the same Kata VM, without crossing the sandbox boundary.
The first sidecar type ships today: docker (Docker-in-VM via docker:27.5-dind). Future types (containerd for nested K3s, etc.) plug into the same registry without touching core.py.
Why sidecars (not Docker-in-Docker)?
Docker-in-Docker (DinD) runsdockerd inside the user container with --privileged and overlay-on-overlay storage. It works but is fragile, has cgroup edge cases, and storage overhead.
The sidecar model separates concerns:
- The daemon runs in its own container — its filesystem, its lifecycle.
- The socket is shared via an
emptyDirvolume that both containers mount. - The daemon’s persistent data (
/var/lib/docker) lives on the Longhorn PVC (kata-qemu-longhorn) or anemptyDir(kata-firecracker-devmapper). - Both containers run inside the same Kata VM — no escape from the sandbox boundary.
Run Docker inside a sandbox
The user container needs the Docker client (
docker CLI). Use docker:27.5-cli as a base or apt install docker.io on Debian/Ubuntu images.Storage and lifecycle
On
kata-qemu-longhorn:
- An init container (
init-state) creates/mnt/state/docker/on the PVC before the sidecar starts. - Pulled images and built layers persist across pause/resume.
k7 forkclones the entire PVC, including the Docker layer cache — the forked sandbox starts with the same images.
kata-firecracker-devmapper:
- Each pod restart wipes the Docker state.
- Fork is unavailable on this backend anyway.
k7d:
- Docker data lives for the lifetime of the VM — pause/resume keep it (nothing is torn down), but it does not survive pod deletion.
- k7d’s warm fork currently supports single-workload sandboxes only; a sidecar-equipped sandbox cannot be forked.
Readiness ordering
When a sidecar is configured, k7 waits for all containers in the pod to beready before marking the sandbox ready (the dockerd readiness probe runs docker info). Your before_script won’t run until the daemon is up.
Available sidecar types
The registry lives insrc/k7/core/sidecar.py:
Adding a new sidecar type is a single registry entry — no changes to the CLI, models, or core orchestration logic.
Network considerations
Sidecar containers share the pod’s network namespace. Traffic spawned by the daemon (Docker containers, registry pulls, etc.) flows through the VM’s network stack and is subject to the sandbox’sNetworkPolicy / CiliumNetworkPolicy. To pull images from outside, whitelist the registry:
Reference
- Sidecar registry:
src/k7/core/sidecar.py - Pod assembly:
src/k7/core/core.py
