content/manuals/ai/sandboxes/migration.md
{{< summary-bar feature_name="Docker Sandboxes" >}}
The most recent versions of Docker Desktop create microVM-based sandboxes, replacing the container-based implementation released in earlier versions. This guide helps you migrate from legacy sandboxes to the new architecture.
Docker Sandboxes now run in lightweight microVMs instead of containers. Each sandbox has a private Docker daemon, better isolation, and network filtering policies.
[!NOTE] If you need to use legacy container-based sandboxes, install Docker Desktop 4.57.
After upgrading to Docker Desktop 4.58 or later:
docker sandbox lsdocker ps -a and docker volume lsdocker sandbox run creates a new microVM-based sandboxChoose the approach that fits your situation:
This is the simplest approach for experimental features. You'll recreate your sandbox with the new architecture.
Note any important configuration or installed packages in your old sandbox.
Remove the old sandbox containers:
$ docker rm -f $(docker ps -q -a --filter="label=docker/sandbox=true")
Remove the credential volume:
$ docker volume rm docker-claude-sandbox-data
Create a new microVM sandbox:
$ docker sandbox create claude ~/project
$ docker sandbox run <sandbox-name>
Reinstall dependencies. Ask the agent to install needed tools:
You: "Install all the tools needed to build and test this project"
Claude: [Installs tools]
What you lose:
ANTHROPIC_API_KEY)What you gain:
If you have extensive customization, preserve your setup by creating a custom template.
Inspect your old sandbox to see what's installed:
$ docker exec <old-sandbox-container> dpkg -l
Create a custom template with your tools:
FROM docker/sandbox-templates:claude-code
USER root
# Install your tools
RUN apt-get update && apt-get install -y \
build-essential \
nodejs \
npm
# Install language-specific packages
RUN npm install -g typescript eslint
# Add any custom configuration
ENV EDITOR=vim
USER agent
Build your template:
$ docker build -t my-sandbox-template:v1 .
Create a new sandbox with your template:
$ docker sandbox create --template my-sandbox-template:v1 claude ~/project
[!NOTE] The
--pull-templateflag was introduced in Docker Desktop 4.61 (Sandbox version 0.12). On Docker Desktop 4.58–4.60, use--load-local-templateto use a locally-built template image.
Run the sandbox:
$ docker sandbox run <sandbox-name>
If you want to share this template with your team, push it to a registry. See Custom templates for details.
After migrating, clean up legacy containers and volumes:
Remove specific sandbox:
$ docker rm -f <old-sandbox-container>
$ docker volume rm docker-claude-sandbox-data
Remove all stopped containers and unused volumes:
$ docker container prune
$ docker volume prune
[!WARNING]
docker volume pruneremoves ALL unused volumes, not just sandbox volumes. Make sure you don't have other important unused volumes before running this command.
Old (container-based):
docker psNew (microVM-based):
docker sandbox ls to see themANTHROPIC_API_KEY environment variable or interactive authOld command structure:
$ docker sandbox run ~/project
New command structure:
$ docker sandbox run claude ~/project
The agent name is now a required parameter when creating sandboxes, and you run the sandbox by name.