blog
Docker Now Runs Inside PandaStack Sandboxes
- written by
- Ajay Kumar
- published
- reading time
- 6 min read
- topics
Docker now runs inside PandaStack sandboxes. Not Docker-in-Docker, not a socket borrowed from the host, not --privileged on a machine other people share: a normal dockerd inside the sandbox's own Firecracker microVM, on that sandbox's own Linux kernel. docker run, docker compose, docker build and Testcontainers behave the way they do on a Linux laptop.
I'm Ajay; I build PandaStack. Until this week, dockerd would not even start in one of our sandboxes. This post covers why, what changed, what an AI agent can do with Docker now, the numbers we measured on production, and the limits worth knowing before you rely on it.
Why Docker did not work before
A sandbox is a microVM, and a microVM boots whatever kernel the platform gives it. Ours was Firecracker's own CI build of Linux 5.10, which is minimal on purpose. Docker asks more of the kernel's packet filter than that build had: dockerd sets up its bridge network with iptables rules, the kernel refused them, and the daemon exited before it ran a single container. Kubernetes hit the same wall another way, because kube-proxy writes every rule with -m comment, a match that build leaves out.
So we built our own guest kernel: Linux 6.1.192 from kernel.org, Firecracker's own 6.1 configuration, and a short list of additions that sandboxes kept asking for. Those are the netfilter matches Docker and kube-proxy use, BPF with type information (BTF) for tracing tools, kprobes and ftrace. Every official template moved to it on November 22, 2026, and templates you build yourself moved on November 23. In our tests it also restores a little faster than 5.10 and uses less memory per idle sandbox.
What an agent can do with Docker
- Run a project's real development stack. Plenty of repositories start Postgres, Redis or a queue with
docker compose upbefore their tests can run. A coding agent in a sandbox can now follow the README as written. - Run Testcontainers suites. Test suites that start throwaway databases through Testcontainers find a local Docker daemon, the way they do on a CI runner.
- Build and try images. An agent that writes or edits a Dockerfile can build it and run the result before it hands the change back, on a machine that is destroyed afterwards.
- Run tools that only ship as an image.
docker runthe scanner, the database or the service instead of installing it by hand. - Show the result to a person. A container's published port gets the sandbox's public preview URL, like any other server in the sandbox.
- Pause a whole running stack. Hibernating a sandbox saves the VM with its containers running inside, and waking it brings them back without restarting anything.
Try it in under a minute
No official template ships Docker yet. In base, install it with apt. The install took 27 to 44 seconds in our runs, so stream it: a blocking exec is cut by the gateway after about 100 seconds.
from pandastack import Sandbox
sbx = Sandbox.create(template="base", ttl_seconds=1800)
sbx.exec_stream(
"apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker.io"
" && systemctl start docker",
on_stdout=lambda s: print(s, end=""),
on_stderr=lambda s: print(s, end=""),
timeout_seconds=300,
)
print(sbx.exec("docker run --rm hello-world", timeout_seconds=120).stdout)
sbx.exec("docker run -d --name web -p 8080:80 nginx:alpine", timeout_seconds=120)
print(sbx.preview_url(8080)) # the nginx welcome page, on a public URLOne detail: in a sandbox the package does not start the daemon by itself, so keep the systemctl start docker. After that, measured on production: Docker 29.1.3 on overlayfs with cgroup v2, hello-world in 1 second, and the nginx page live on its preview URL 4 seconds after docker run.
Bake it into a template so it starts ready
Paying that install in every sandbox adds up. Build a template with Docker in it once instead. A template is baked into a snapshot after it boots, and the daemon is running by then, so every sandbox made from it starts with Docker already up.
FROM ubuntu:24.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
docker.io docker-compose-v2 docker-buildx iptables ca-certificates curl \
&& mkdir -p /etc/docker \
&& echo '{"registry-mirrors": ["https://mirror.gcr.io"]}' > /etc/docker/daemon.json \
&& rm -rf /var/lib/apt/lists/*from pandastack import Client, Sandbox
client = Client()
build = client.templates.build_from_dockerfile(
"docker-box", "Dockerfile", memory_mb=4096, size_mb=4096,
)
client.templates.wait_for_build(build.id)
sbx = Sandbox.create(template="docker-box")
print(sbx.exec("docker run --rm hello-world").stdout) # no install stepOur test build of a Dockerfile like this one took about five minutes. The sandbox it produced came up with Docker running and ran hello-world in 2 seconds. One catch: a template's kernel is fixed when it is built, so a custom template you built before November 23 is still on 5.10, where dockerd exits at start. Build it again with the same command.
Compose, Testcontainers and docker build
These are the checks we ran on production before writing this, each in a fresh base sandbox with Docker installed as above. The docs page linked at the end has the full commands.
| What | How | Result |
|---|---|---|
| Docker Compose | The docker-compose-v2 package; Postgres 16 and Redis 7 in one compose.yaml | Both ready 21 s after docker compose up -d, image pulls included |
| Testcontainers | The Python library and a Redis container | Test passed in 3 s, after an 8 s pip install |
| docker build | The docker-buildx package and a two-step Alpine image | Built in 2 s, and the container ran |
| Published port | nginx:alpine with -p 8080:80 | Served on the sandbox's public preview URL 4 s after docker run |
| Hibernate and wake | A 4 GiB sandbox with nginx running | 48 s to save, 2 s to wake, nginx still up and serving |
The limits, honestly
- Docker Hub's pull limit. Docker Hub allowed 100 anonymous pulls per hour from our machines' address when we checked, and every sandbox on the same machine shares that address. The Dockerfile above points Docker at Google's free mirror of Docker Hub,
mirror.gcr.io. Docker asks the mirror first and falls back to Docker Hub for anything the mirror lacks. Logging in to Docker Hub works too. - Disk. Images and containers live on the sandbox's own disk.
basehas about 7.6 GB free, so slim images go further. - Memory. Containers share the sandbox's memory: 4 GiB in
base, and whatever you bake into your own template. A compose stack with a database fits; a cluster does not. - Long commands. The load balancer in front of our API ends any response at 5 minutes, so a streamed command that runs longer is cut, while the command itself keeps running in the sandbox. Start long builds in the background and poll a log file.
- Not preinstalled. No official template ships Docker yet. Until one does, install it or bake your own.
Why not Docker-in-Docker on a shared host
The usual way to give a job Docker is a privileged container, or the host's Docker socket mounted into it. Both hand the job the host. A privileged container can reach the host kernel's devices, and whoever holds the socket can start a container that mounts the host's disk. That is acceptable on a CI runner you own and throw away. It is not acceptable where many customers share a machine.
In a sandbox, the kernel belongs to that sandbox alone. The daemon runs as root inside the VM, which is what Docker expects, and the boundary that matters sits one level down, at the hypervisor. A container that misbehaves can wreck the sandbox it runs in, and that sandbox is disposable.
faq
Frequently asked questions
Can you run Docker inside a PandaStack sandbox?
Yes, since November 2026. Every official template boots our Linux 6.1 kernel, which Docker needs, and so does every template you build since November 23, 2026. Docker itself is not preinstalled: install the docker.io package, which takes under a minute, or bake it into your own template.
Do I need --privileged or the host's Docker socket?
No. The daemon runs inside the sandbox's own microVM, on that VM's kernel. Nothing from the host is shared with the containers you start.
Does docker compose work in a sandbox?
Yes. Install Ubuntu's docker-compose-v2 package and run docker compose up -d. In our test, Postgres 16 and Redis 7 were ready 21 seconds later, image pulls included.
Will Docker Hub rate-limit my sandboxes?
It can. Anonymous pulls are limited per address, and sandboxes on the same machine share one. Set the free mirror.gcr.io mirror in /etc/docker/daemon.json, or log in to Docker Hub.
What happens to running containers when a sandbox hibernates?
They are saved with the VM and are still running after a wake. In our test, a 4 GiB sandbox with nginx running took 48 seconds to hibernate and 2 seconds to wake, and nginx kept serving.
Why does Docker fail in my custom template?
A template's kernel is fixed when it is built. Custom templates built before November 23, 2026 boot Linux 5.10, where dockerd exits at start. Build the template again; uname -r in a sandbox should then show 6.1.
links
Keep reading
- Docker in a sandbox (docs) — Every command from this post, the registry mirror, and troubleshooting.
- Docker-in-Docker vs microVMs for CI builds — Why a nested daemon on a shared runner is the wrong trade, and what a VM per build changes.
- Testcontainers, and what comes after it — Throwaway databases for tests, and when a snapshot beats starting containers.
- Building container images for untrusted repos without privileged Docker — The builder-template pattern, with layer caching.
- You ship the kernel: Firecracker guest 5.10 vs 6.1 — What a newer guest kernel unlocks, and why switching means a re-bake.
- Why Docker isn't a sandbox — Containers share the host kernel; the boundary has to sit lower.
more posts
Related posts
- PandaStack vs Gitpod / Ona: A Workspace Is Not a Sandbox
Gitpod was right about disposable development environments before most of the industry agreed. The divergence is not quality, it is the unit: a workspace a person opens, versus a sandbox an API call creates and throws away 400 times.
- Firecracker vs Podman: which runs untrusted code?
Podman is a genuinely better container engine than rootful Docker — daemonless, rootless, user namespaces on by default. But rootless is a great seatbelt; it is still not a separate car. For untrusted code you want a microVM.
- PandaStack vs Replit
Replit Agent builds an app for you, inside Replit's own browser tab. PandaStack doesn't build anything — it's the compute layer underneath somebody else's agent, including possibly yours. Different jobs wearing similar marketing copy.
- PandaStack vs Morph Cloud: Snapshot-First Sandboxes
Morph and PandaStack both treat snapshot-and-branch as the core primitive rather than an afterthought. A fair, founder's guide to evaluating the two.
- The best Cloudflare Containers alternatives in 2026
Cloudflare Containers exist because Workers cannot run ffmpeg. They are a good answer to that, with an unusual shape: no public ingress, a Durable Object as the control plane, and sizes chosen from a short list. Here is when to look elsewhere.
More in AI agent sandboxes · See AI agent sandboxes on PandaStack
pandastack
Run code in a microVM in one API call.
50–100 ms cold start. Fork, snapshot, and scale to zero.
measured on the host; your network round trip is extra