Secure by Default
Docker Sandboxes & Docker Compose Meets AI
Marco Franzon · Trento · 2026
Welcome everyone. Today we'll talk about how Docker evolved into a native platform for safe, autonomous AI agents.
A True Story
"I gave Claude Code full access to my laptop…
it deleted my node_modules in 3 seconds. "
Start with the scary scenario. Most people in this room have run AI coding agents without any isolation. Let that sink in.
Now Watch This
docker sandbox run claude ~/my-project
Same agent. Same power. Zero risk to your host.
One command. That's all it takes. The agent runs with full autonomy but can't touch anything outside your project.
Quick Poll
Who has run an AI coding agent locallywithout any isolation?
🙋 Raise your hand, no judgment (yet)
Expect 70%+ hands. This sets up the "why" for the rest of the talk.
The Thesis
In the age of AI agents that run arbitrary code , Docker gives us secure-by-default isolation . no manual hardening required.
Docker Sandboxes + Compose = the new developer superpower
This is what we'll prove today. Secure by default means you don't have to be a security expert to be safe.
Why "Secure by Default" Matters for AI
AI agents are powerful but dangerous
Hallucinations → rm -rf /
Prompt injection → data exfiltration
Agents install packages, run scripts, modify files
They need autonomy , but we need boundaries
Claude Code, Copilot CLI, Gemini CLI, Codex: all can execute arbitrary shell commands. The power is real. So is the risk.
The Agent Landscape (2026)
Claude Code (Anthropic)
Codex CLI (OpenAI)
Gemini CLI (Google)
GitHub Copilot CLI
OpenCode, Kiro, cagent…
All of them want to: read files, run commands, install packages, build & test.
This isn't one tool, it's a whole category. Every major AI lab ships a coding agent. They all need the same thing: safe execution.
Containers: The Original Sandbox
Isolation Layers
Namespaces (PID, NET, MNT, USER)
cgroups (resource limits)
Dropped capabilities
seccomp / AppArmor / SELinux
Hardening Options
Rootless mode
Read-only filesystems
--no-new-privileges
User remapping
Docker containers already provide many isolation layers. But there's a fundamental limitation…
The Problem with Containers
Containers share the host kernel
A kernel exploit inside a container = host compromise
For untrusted AI-generated code, containers alone are not enough .
You don't want to remember: --cap-drop=ALL --security-opt=no-new-privileges --read-only every time
This is the key insight. Containers are great for your own code. But when an AI agent generates and runs arbitrary code, you need a stronger boundary.
Compose: Security Built-in
services:
agent-executor:
image: my-agent:latest
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
deploy:
resources:
limits:
cpus: "2"
memory: 4G
networks:
- isolated
secrets:
- api_key
networks:
isolated:
internal: true
secrets:
api_key:
environment: "AGENT_API_KEY"
Compose gives you declarative security. read_only, cap_drop ALL, resource limits, isolated networks, secrets management, all in YAML.
Docker Sandboxes
The MicroVM Revolution
Docker Desktop 4.58+ · macOS & Windows
Each agent runs in a lightweight microVM with its own private Docker daemon
This is the star of the show. Docker Sandboxes, introduced in Desktop 4.58, use real virtual machines, not containers. This changes everything.
Architecture
HOST MACHINE
MicroVM (Sandbox)
Private Docker Daemon
Isolated from host
AI Agent
Claude Code, Codex…
📁 Workspace sync
Bidirectional file sync
🌐 Network proxy
HTTP/HTTPS filtered
macOS: virtualization.framework · Windows: Hyper-V
The microVM has its own kernel, its own Docker daemon, and only your project folder is synced. The agent can docker build, docker run, docker compose up, all inside the VM.
Security Properties
Separate kernel : no shared kernel exploits
Private Docker daemon : no socket escape
Bidirectional file sync : only your workspace, not volume mounts
Network filtering proxy : HTTP/HTTPS only, raw TCP/UDP blocked
No access to host localhost, private networks, cloud metadata
Instant cleanup : docker sandbox rm
Zero host filesystem access outside workspace. Private daemon means no Docker socket escape. MicroVM boundary means kernel exploit containment. This is real isolation.
Network Policies
Blocked by Default
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
127.0.0.0/8 (localhost)
169.254.0.0/16 (cloud metadata)
Two Modes
Allow mode : all except blocked CIDRs
Deny mode : only allowed hosts
docker sandbox network proxy \
my-sandbox \
--policy deny \
--allow-host "*.npmjs.org"
The filtering proxy gives you fine-grained control. Allow mode for development, deny mode for untrusted code. You can monitor everything with docker sandbox network log.
"YOLO Mode", But Safe
Agents run unsupervised , no permission pop-ups
They can:
Edit code, install packages
docker build inside the sandbox
docker compose up full stacks
Run tests, linters, formatters
All safely isolated. You sleep at night.
"YOLO mode, but make it enterprise-compliant." The agent has full autonomy within its boundary. That's Level 4 autonomy without the risk.
🎬 Live Demo
# Create a sandbox for your project
docker sandbox run claude ~/my-project
# The agent edits code, installs packages, runs tests
# All inside the microVM, zero host impact
# Check running sandboxes
docker sandbox ls
# Peek inside
docker sandbox exec -it claude-my-project bash
# Clean up
docker sandbox rm claude-my-project
Show the real thing. Create a sandbox, let Claude Code work on a project, show that host is unaffected. Run docker ps to show sandboxes don't appear there.
Isolation Approaches Compared
Approach Isolation Agent Can Docker? DX Secure by Default?
Plain Docker Low Yes (risky) Great No
gVisor / Kata Medium/High Limited OK Almost
Full VM High Yes Poor Yes
Docker Sandboxes High Yes (safe) Best Yes
This is the money slide. Docker Sandboxes give you VM-level isolation with container-level DX. No other approach hits all four columns.
Docker Compose Meets AI
Compose isn't just for web apps anymore.
New AI-native patterns:
Models + MCP gateways + tools in one compose.yaml
Sandboxed agent executors alongside your services
Agents spinning up full Compose stacks for integration testing
Compose gives you the orchestration layer. Define your entire AI stack declaratively. The agent can compose up a whole test environment inside its sandbox.
Docker Model Runner
Run AI models as first-class Compose services
Docker Desktop 4.41+ · Compose v2.35+
Pull & run LLMs with docker compose up
OpenAI-compatible API, zero config
Auto-injected env vars for endpoints
Embeddings, chat, deterministic modes
Docker Model Runner lets you declare AI models right in your compose.yaml. Compose pulls and runs the model automatically, and your services get the endpoint URL injected as environment variables. It's an OpenAI-compatible API out of the box.
Models in Compose
The models Top-Level Element
models:
llm:
model: ai/smollm2
context_size: 4096
embeddings:
model: ai/all-minilm
services:
app:
image: my-ai-app
models: [llm, embeddings]
Short syntax : auto-generated env vars
LLM_URL
LLM_MODEL
EMBEDDINGS_URL
EMBEDDINGS_MODEL
Your app just reads the env vars and talks to the model. No setup needed .
The models top-level element is the new recommended syntax; the old provider syntax is deprecated. You declare models by name, and services reference them. Compose auto-generates URL and MODEL environment variables following a naming convention.
Model Runner: Fine-Tuning
Custom Env Vars (Long Syntax)
services:
app:
image: my-app
models:
llm:
endpoint_var: AI_MODEL_URL
model_var: AI_MODEL_NAME
Runtime Presets
models:
# Deterministic (evals, CI)
eval-model:
model: ai/smollm2
context_size: 4096
runtime_flags:
- "--temp"
- "0"
- "--top-k"
- "1"
# Creative (content gen)
creative-model:
model: ai/smollm2
runtime_flags:
- "--temp"
- "1"
- "--top-p"
- "0.9"
Long syntax lets you pick your own environment variable names. Runtime flags give you full control over inference: deterministic for CI, creative for content generation, concurrent mode with threading for throughput.
Local Models + Sandboxes
Run coding agents inside sandboxes backed by a local model, no cloud, no API keys.
docker-compose.yml
services:
agent:
image: my-coding-agent
models:
llm:
model: ai/qwen2.5-coder
environment:
- OPENAI_BASE_URL=${AI_MODEL_ENDPOINT_URL}
- OPENAI_MODEL=${AI_MODEL_NAME}
opencode config
{
"model": "qwen2.5-coder",
"providers": {
"docker-model-runner": {
"name": "Docker Model Runner",
"baseURL": "${OPENAI_BASE_URL}",
"models": {
"qwen2.5-coder": {
"name": "qwen2.5-coder"
}
}
}
}
}
Docker Model Runner exposes an OpenAI-compatible endpoint. The sandbox injects OPENAI_BASE_URL automatically via the models key in Compose. opencode picks it up through its provider config — fully air-gapped, no API keys, no data leaving the machine.
Try It Today
# 1. Update Docker Desktop to 4.58+
# 2. Run your first sandbox
docker sandbox run claude ~/your-project
# 3. Ship safer agents tomorrow
Docker Model Runner:
# Pull and run a local model
docker model pull ai/llama3.2
# Chat with it directly
docker model run ai/llama3.2 "Explain Docker sandboxes in one sentence"
Resources:
Give them the links. Encourage them to try it today. The barrier to entry is literally one command.
Thank You!
Questions?
🐳 Secure by default. Ship with confidence.
Open for questions. Thank the audience.