Day 48 of 52 · about 25 min · Safety · Bonus
Give Claude a safe box with a dev container
Before you leave Claude running unattended, decide what it can reach. In a dev container its commands run inside a container instead of on your machine, but your project files and the network are still in play.
You’ll finish with
- A
devcontainer.jsonwith the official Claude Code feature - Claude Code signed in and running inside the container
- A clear picture of what the container holds back and what it doesn’t
You’ll need
- Docker running, and VS Code with the Dev Containers extension
- The practice project, or a repository you trust
Before you start
Tell us about your setup and the steps change to fit it. Your answers stay in this browser, and you can change them at any time.
Which system are you on?
Commands differ between systems. Pick the one you’ll run Claude Code on.
The steps
One step at a time. When a step’s check matches, tick it and the next one opens.
Step 1 of 3: Add the Claude Code feature
Create .devcontainer/devcontainer.json with the official Claude Code feature.Save this file in your project, by hand or by pasting the prompt into Claude Code. The feature installs Claude Code, and Node.js if the image lacks it. With your own image or Dockerfile, add only the
featuresblock.Or let Claude create itCreate .devcontainer/devcontainer.json in this project with exactly this content, and nothing else: { "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {} } }Changes to .devcontainer/devcontainer.json
Added: {Added: "image": "mcr.microsoft.com/devcontainers/base:ubuntu",Added: "features": {Added: "ghcr.io/anthropics/devcontainer-features/claude-code:1.0": {}Added: }Added: }The :1.0tag pins the feature’s install script, not the Claude Code version.Check it worked
The file sits at
.devcontainer/devcontainer.jsonin your project’s top folder.Step 2 of 3: Open the project in the container
Rebuild the container in VS Code, then sign in to Claude Code inside it.Open the Command Palette (
Cmd+Shift+Pon Mac,Ctrl+Shift+Pon Windows and Linux) and run Dev Containers: Reopen in Container (or Rebuild Container if you’re already in one). When it finishes, open a terminal in VS Code.TerminalRun: claude
What happens: Follow the sign-in prompt. If the browser never hands back, paste its code at
Paste code here if prompted.This terminal runs inside the container, not on your machine. Check it worked
Claude Code starts in the VS Code terminal and you are signed in.
If it didn’t work
The build stops with Failed to install Node.js and npm
Add
"ghcr.io/devcontainers/features/node:1": {}to thefeaturesblock, above the Claude Code feature, and rebuild.Step 3 of 3: Know what the box holds back
Commands stay in the container. Your project files and the network don’t.Ask Claude to add a comment to a file. Claude and its commands run inside the container, but the edit lands in your real project folder, because the container mounts it from your machine.
Kept inside the container
- Commands Claude runs, and what they install
Still reachable
- Every file in your mounted project folder
- The network, unless you restrict outbound traffic
- Credentials in the container’s
~/.claude, and anything you mount
Don’t mount host secrets such as ~/.ssh. Prefer short-lived, repository-scoped tokens.Warning: With
--dangerously-skip-permissions, a malicious project can send out anything in the container, your Claude credentials included. Use the container only with repositories you trust.Check it worked
The comment Claude added shows in the file on your machine, outside the container.
Finish · 3 of 3 steps to go
Claude works inside a box you control
What you’ll have checked
devcontainer.jsonholds the Claude Code feature- Claude Code runs and is signed in inside the container
Lesson updates by email
Get lesson updates by email
Leave your email and we’ll tell you when we add or update a lesson.
Claude Code for your team
Want Claude Code set up across your team?
HorizonLux sets up and repairs Claude Code for teams: CLAUDE.md rules, hooks that enforce them and reviewed MCP servers. Book a free call to talk it through.
Related
Questions
Questions about Day 48
What about the reference container?
It adds an egress firewall and persistent volumes. The docs call it a working example, not a maintained base image. To use it, copy its `.devcontainer/` folder and adjust the Dockerfile for your tools.
Sources
Checked against the official Claude Code docs on .
Independent resource, not affiliated with Anthropic. HorizonLux wrote this lesson; Claude Code is made by Anthropic.