Podman, MicroVMs Or The Cloud: Safer Ways To Run Docker In A Dev Container

Podman, MicroVMs Or The Cloud: Safer Ways To Run Docker In A Dev Container

Jean-Baptiste Kaiser
• 17 min read

In a previous blog post, we briefly introduced Dev Containers: what they are, how to run them, and how to extend them. We also had a dedicated section about running Docker inside a Dev Container, since applications based on a Docker stack are very common.

You’d think installing the official Docker-in-Docker (DinD) feature is enough. It isn’t.

I mean sure, it works. But it also opens a big hole in Docker’s isolation: the DinD feature requires the Dev Container to run in --privileged mode, which lets anyone inside the container perform privileged actions such as creating a new container mounting the complete host filesystem.

This is especially problematic if you plan to run autonomous coding agents (Claude Code, Codex, Copilot, …) inside your Dev Container. What are the risks? How to mitigate them? Let’s dive in.

A Privileged Container Can Take Over Your Host

We already covered the risks induced by enabling DinD in the previous blog post, but to sum up: DinD (or privileged) containers let an attacker mount the host disk (e.g. /dev/sda) or abuse kernel capabilities to run code as host root.

Concretely, an attacker can then bypass all sandbox mitigations you might have in place, like limiting access to the host FS, to your credentials, or bypass your sandbox firewall.

This opens the door to data/credential theft, impersonation, malware infection and propagation, host compromise, resource hijacking, and more…

Meme showing judge Steve Harvey Grimacing

In the other blog post we already explained how you can avoid this threat, by suggesting alternative architectures which remove the need for DinD.

But what if you can’t use those alternatives, and really need to deploy a Docker stack in order to start your app? We personally stumbled accross this issue because many of our apps are using Supabase, and their CLI doesn’t allow customizing the container images.

I see four ways to solve this:

  1. Using a Docker Socket Proxy, like Tecnativa’s proxy, to limit what docker can do
  2. Using alternative docker runtimes or engines, such as Podman or Sysbox, to remove the need for root and --privileged
  3. Wrapping the container in a VM, or rather a microVM, such as multipass, microsandbox, nixbox or docker sandboxes, to provide an additional isolation layer around the container
  4. Running your container in a VM in the cloud, e.g. by using Claude Code Web, GitHub Codespaces, Gitpod or Coder, to avoid exposing your host completely

I took some time to explore each one to various degrees. There is no one-size-fits-all solution, but knowing the options should help you pick yours.

Docker Socket Proxy: Safer, But Mostly Read-Only

One of the easiest solutions you can try is wrapping the Docker socket with a proxy, like Tecnativa’s Docker Socket Proxy, which will improve security by only allowing some operations and blocking the others.

For instance you can authorize read-only operations, like docker ps, docker logs or docker inspect, and block dangerous operations like docker run or docker exec.

To use it, you need to start a first container running the API proxy and mount the Docker socket into it:

Terminal window
docker container run \
-d --privileged \
--name dockerproxy \
-v /var/run/docker.sock:/var/run/docker.sock \
-p 127.0.0.1:2375:2375 \
tecnativa/docker-socket-proxy

Then, you can connect the local Docker client to that socket:

Terminal window
export DOCKER_HOST=tcp://localhost:2375

From now on, all operations that are not explicitly authorized will be blocked:

Terminal window
docker run hello-world
Error response from daemon: <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>

This solution can be useful, as it allows the coding agent in your Dev Container to be able to inspect and debug the Docker stack, while outright refusing dangerous operations.

However, you might have noticed that this does not really answer our need, as it wouldn’t allow the agent in our container to start Supabase for instance. For our use-case we need something else.

Alternative Runtimes: Running Docker Without Root

Sysbox: No —privileged, But Linux Only

Sysbox logo

Docker comes with its own default runtime called runc. But it is possible to use alternative runtimes, such as Sysbox, which offers an additional isolation to run Docker in Docker without requiring a --privileged container.

Inside it, it becomes possible to run a real Docker daemon (dockerd), or systemd or even Kubernetes, without --privileged.

However, it is worth mentioning that Sysbox requires a fairly heavy host setup: you’ll need to install a .deb package, 2 systemd daemons (sysbox-mgr, sysbox-fs) and you will need to restart the Docker daemon. What’s more, Sysbox is only available on Linux! You can’t use it on macOS/Windows since Docker Desktop doesn’t support installing a runtime in its VM.

So, this might work but comes with significant tradeoffs, notably portability.

Rootless Podman: Safer, But Not A Drop-In Replacement

Podman logo

Another approach is to replace the Docker Engine itself by Podman, an open source container engine which requires no daemon, and natively supports rootless.

What is rootless Docker

As the name implies, it refers to running the container engine as a non-root user. The idea is that if a process manages to escape its container, it can then run arbitrary code with the same permissions as the container engine’s owner, i.e. in most cases root. Rootless Docker prevents that.

Disambiguation: rootless Docker vs. non-root container

This is not the same as running a process using a non-root user inside the container, which is also a good practice! Indeed, even without a sandbox escape, running a process as root inside the container means it has authority to tamper with the container’s own internals: editing /etc/hosts, /etc/resolv.conf or /etc/ssl/certs to intercept TLS traffic, or even neutralize container protections such as iptables rules. Running a non-root container means the process in the container does not run as root, which closes such attack vectors.

We’ll discuss non-root containers in an upcoming article.

There are two places where we can swap Docker with Podman: on the host and in the Dev Container. Which leaves us with three options to try:

  • Option 1: Docker rootful on host, Podman rootless in container
  • Option 2: Podman rootless on host, Docker rootful in container
  • Option 3: Podman rootless for both

I tested all three, and each one let me run Supabase inside the Dev Container.

Surprisingly, all three required relaxing some security settings:

  • Option 1 requires adding 6 capabilities (SYS_ADMIN, NET_ADMIN, …), modifying seccomp, disabling AppArmor and unmasking /proc
  • Option 2 requires adding 6 capabilities (in userns though) + ip_forward
  • Option 3 requires only 3 capabilities (in userns) but also requires tun and unmasking /proc

Going over the consequences of removing each above-mentioned security layer would probably double the size of this post. In short: remove as few protections as possible.

Some adjustments were also needed for Supabase specifically, as notably Docker and Podman do not implement healthcheck pollers the same way.

All three options differ on various aspects, like what the attacker needs to get out, where they would land (root, my user or a subordinate user), which security settings must be relaxed and also what patch-up jobs are needed.

DinD / DooD
Docker in Docker rootful
Option 1
Podman rootless in Docker rootful
Option 2
Docker in Podman rootless
Option 3
Podman in Podman rootless
What the attacker needs to get out🔴 A simple command🟠 A kernel exploit, or a SYS_ADMIN abuse🟢 A kernel exploit🟢 A kernel exploit
Where they land from the app🔴 root🔴 root🟢 subordinate UID🟠 Your host user
Where they land from the agent🔴 root🔴 root🟠 Your host user🟠 Your host user
Security looseningsNone, but socket has everything🔴 6, incl. modified seccomp, disabled AppArmor, unmasked /proc and real SYS_ADMIN🟠 6 capabilities (all in userns) + ip_forward🟢 3: SYS_ADMIN (in userns), tun, unmasked /proc
Protections keptN/A🔴 Little🟢 seccomp, masked /proc, no peripherals🟠 seccomp; /proc unmasked; tun available
Patch-upsNone🔴 Poller + docker shim🟢 None🟠 Poller + starter script

(🟢 favorable · 🟠 acceptable / uncertain · 🔴 unfavorable)

I expected Podman to be a drop-in replacement. It isn’t.

To me, the bottom line of these experiments is that the best compromise is probably Option 2, since it’s much more secure than Option 1, leads to only a subordinate user on escape, and doesn’t require a custom poller or shim. Option 3 needs fewer loosenings, but an escape lands as your host user rather than a subordinate one.

This solution already provides a strong security layer around your agent while allowing it to run a Docker stack without busting security. This is, in my opinion, already a very good way to securely run Docker in a Dev Container.

However, I found the barrier to entry to be arguably high (with additional tooling, configuration and adaptation), and I was surprised to still have to loosen part of the security to get it working.

I knew that if I wanted even stronger isolation (i.e. from kernel exploits), Docker would no longer be enough, and I’d have to move to a Virtual Machine (VM).

MicroVMs: Stronger Isolation, Heavier On RAM

Using a microVM seems like a good solution to run coding agents inside a sandboxed environment with a strong isolation layer, while avoiding the resource and performance costs of a real (traditional) VM, which can be crucial if you plan to run multiple agents in parallel, like most people do nowadays.

What are microVMs

MicroVMs are lightweight virtual machines designed to provide the isolation and security of traditional VMs while approaching the speed and efficiency of containers. Essentially, a microVM strips away all extraneous virtualization features (legacy device emulation, expansive hardware support, etc.) and runs with minimal overhead. (source)

Do I still need a Dev Container if I already use a microVM?

Remember, security is not the only purpose of Dev Containers. Their primary objective is to standardize the development environment, making it configurable and reproducible. So yes, it is perfectly valid to combine a VM and a Dev Container, as they serve complementary goals.

How do I use my IDE / my Coding Agent inside a microVM?

It turns out most popular IDEs have extensions allowing them to work with remote code over SSH. I used VSCode’s Remote-SSH plugin, but there are likely similar plugins for other IDEs. Newer versions of the Claude Desktop app also natively support connecting over SSH.

Remote-SSH reaches the source code over SSH, automatically forwards terminal sessions and open ports. For most coding agents this should be enough. For instance you can use the claude CLI inside the VM, and expose the 54545 port to sign in to your Claude.ai account using your host browser.

Keep in mind however, that you will have to deal with classic difficulties found when working with VMs: file/folder permissions, file/folder mapping or network configuration. Some operations might also become more cumbersome, as accessing the FS over SSH can be slow, and VMs (even microVMs) do introduce performance overheads, and consume significant RAM.

I tried four solutions, each time with the same goal: running Supabase securely.

  • Multipass: Canonical-backed tool that spawns an instant Ubuntu VM with one command (Windows, macOS, Linux). Robust, stable, and scriptable via cloud-init, but general-purpose: you must install the dev tools and set up egress filtering yourself.
  • Microsandbox: Beta microVM sandbox with a built-in network proxy offering egress allowlists and a secrets model (placeholders swapped for real credentials at request time, so they never reach the guest). However I could not get Supabase to start inside it.
  • Nixbox: KVM-isolated microVM built from a reproducible Nix image, with built-in egress filtering and limited performance overhead. Linux only however, filters by hostname rather than IP, and the project is very young.
  • Docker Sandboxes: Docker’s own microVM solution for running AI agents, with sudo and docker preinstalled, credential injection, an outbound network allowlist, and agent-specific features (shared skills, MCP gateway). Supabase worked on it first try; the main drawback is higher memory use than plain Docker. Worth checking out!

Here is a recap of my findings.

MultipassMicrosandboxNixboxDocker Sandboxes
Multi-OS✅✅❌ Linux only✅
Egress filtering❌✅⚠️ By hostname, not IP✅
Secrets kept out of the guest❌✅❌ Not mentioned✅
Built for agents❌ General-purpose✅✅✅
Docker preinstalled⚠️ Via cloud-init❌ Not by default (pick your OCI image)✅✅
Supabase works✅ With some difficulties❌✅ With some difficulties✅ First try
Reproducible⚠️ Via cloud-init⚠️ Via OCI images✅ Nix-built image⚠️ Via “Kits” (OCI images)
Maturity✅ Mature (Canonical)⚠️ Beta❌ Very young (13 ⭐)⚠️ Recent, closed source
RAM / performance⚠️ Classic VM overhead✅ Fast boot (~320 ms), RAM undocumented✅ Low overhead (56 s vs 48 s)⚠️ Memory-hungry

(✅ yes, ⚠️ partial or with caveats, ❌ no)

As you can see, most solutions succeeded (with more or less ease) in running a Dev Container with Supabase, so they can be viable solutions. However, they can require a significant effort to set up initially, and unavoidably bring a small performance overhead, and above all higher memory consumption.

To me, this was also a major concern, since my personal hardware is simply too limited to comfortably run, say, more than three of these VMs in parallel.

That’s why I eventually turned my attention to cloud based solutions.

Moving To The Cloud With Claude Code Web

As I mentioned earlier, there are many solutions out there offering to run both your app and your agent in the cloud: Claude Code Web, GitHub Codespaces, Gitpod, Coder and probably others…

It turns out our Claude subscription includes Claude Code Web without additional cost, so I chose to give it a try!

In a nutshell, Claude Code Web is a cloud service allowing you to spawn microVMs that run in the cloud, and come pre-configured with coding tools like Python, Node.js, PHP, Java, Docker, …, and, you guessed it, Claude Code. It lets you select one or several GitHub repositories to connect to, and offers features like network filtering out of the box.

After several weeks of using it, here are my takeaways.

The Downsides: No Public Port, Short Idle Timeout, Painful Setup

Claude Code Web comes with major limitations and downsides, which can even make it impractical for certain use-cases.

My first frustration: you cannot expose a port out to the internet! This means that, if you are working on a web application, you are limited to viewing screenshots of Claude using your app. Fortunately, there are ways around that (see below).

The second source of frustration to me was the environment setup. While many tools are installed by default, you’ll probably need to perform some additional operations to prepare your app, or you may want a different version from the default ones. The setup-script is the place to do such things, but it has to complete within 5 minutes, and it can be a pain to test it and iterate until you find a version that works. You can’t hot reload the environment, and are forced to start a new session to test your changes.

I was also surprised by how hard it can get to use your own skills, rules, hooks or MCPs in there! Any part of the harness that’s stored at the repository level will work just fine, but any personal rule or workflow you might have won’t be available by default. There were only two ways I found to use my personal harness in cloud instances. The first one is to make it into a plugin, and then install and enable this plugin from the claude.ai website. Doing it from the Desktop app won’t work. And the second one is to manually clone my harness repo and install it as part of the setup-script.

Of course there are also resource limitations. As of today there are 4 vCPU, 16 GB of RAM and 30 GB disk. They should be fine for most usages, but can be too limiting for others.

Occasionally you’ll run into 429 Too Many Requests when accessing Docker Hub, probably because their VMs access the internet via the same gateways, which trigger Docker’s IP rate limiting.

Lastly, a very annoying limitation is the ridiculous idle timeout configured for cloud sessions. Their doc isn’t very clear about its value, but I’ve never seen a session last more than 5 minutes before being put to sleep. This notably means that background processes can get killed mid-task, sometimes without even Claude knowing about it. This also means an additional overhead for waiting for the environment to resume. Fortunately the filesystem is snapshotted, so you don’t lose your files.

The Upsides: Parallel Sessions And Isolation For Free

Despite the many frustration points listed above, I keep finding myself coming back to Claude Code Web because it offers some serious advantages over local sessions.

The first one is obviously due to its cloud-based nature: you can start a session anytime, from any device, and run as many as you like in parallel without slowing your computer down. It’s also available 24/7 and won’t require keeping your computer on all the time. It’s really a game-changer for parallelisation and automation, and can for sure boost your productivity by a lot.

It also increases security a great deal, almost for free! Isolation is now enforced by a microVM (using Firecracker under the hood), managed by Anthropic’s security experts. This greatly lowers the risk of accidentally exposing personal files or neighboring projects to the agent, or the agent installing a backdoor on your system.

It also comes with a GitHub proxy that lets you selectively grant access to your GitHub repositories, which removes the hassle of having to manage fine-grained tokens yourself to obtain the same level of security (especially in this day and age of supply chain attacks).

I also appreciate that they natively offer a way to restrict the network egress, proving once more that this is a real attack vector not to be underestimated.

Screen capture showing Claude Code Web network egress filter settings

They also recently added network secrets, which let you avoid exposing secrets to the agent at all, only resolving its actual value in the network proxy at request time.

Another key benefit of running in the cloud is that it removes the need to install every tool on your machine. This removes the hassle of having multiple Node.js/Java/PHP/… versions at once, or headaches caused by not picking the correct version for this specific app. It also means you can try out new ones without polluting your system!

Exposing A Cloud Session With Tailscale

Claude Code Web comes with Chromium pre-installed. But, by default, Claude can only drive it through Playwright and can only do screenshots.

I found that to be incredibly frustrating, and was also disappointed to discover that you can’t even use ngrok to circumvent this limitation (it uses a protocol incompatible with the VM’s network proxy, and Claude itself will talk you out of using it).

However, Jérôme, a brilliant colleague of mine, just found out that you can use Tailscale (or any compatible solution) to expose your app. He even built a hook around it to automatically start the tunnel when a new session starts, and resume it when the environment wakes from sleep.

Tailscale logo

So that’s at least one way to get around this limitation.

You will still run into the very short idle timeout discussed earlier, but to get a quick overview of a feature Claude just shipped, this is a neat trick!

Conclusion

Researching this article turned out to be a real journey. I came into this topic looking for a way to securely run a Docker stack inside a Dev Container, learned a lot about alternative runtimes and engines in the process, and eventually realized there are plenty of solutions which all come with some compromise. Still, the best one for me is probably the one I called Option 2 (Podman rootless on the host, vanilla Docker in the container).

As a natural next step I investigated Virtual Machines (VM), discovered microVMs and even hoped they would open the door to more parallelisation, before realizing that they were still too resource intensive for my (somewhat aging) hardware.

The real surprise came when I tried a cloud-based solution (Claude Code Web). Despite its limitations (ridiculous idle timeout, no built-in way to test in the browser, painful setup, resource restrictions, …), its benefits outweigh the frustrations, at least for me. I now tend to default to cloud sessions, only resorting to local sessions when cloud is not an option.

Now, the goal of this post was not to convince you to switch to using cloud sessions at once. This part is only my own feedback and opinion. But still, if this article has been useful in helping you better understand the risks of running a Docker stack in a Dev Container, and how to mitigate them, I’ll consider my goal achieved.

I’m already planning another post on how to securely run Agents in Dev Containers (as this comes with its own challenges too!), so stay tuned for that one as well if this is a topic you’re interested in!

Authors

Jean-Baptiste Kaiser

Full-stack web developer at marmelab, JB is a Software Engineer with a strong Java experience. He plays the piano and runs fast, and not only because he has long fingers and tall legs.

Ready to build something extraordinary?
Our team of talented full-stack developers is ready to tackle your next web or mobile project. Let's build it together!