Skip to content

About

Claude code sandboxed container

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

Claude Sandbox

Docker configuration to run Claude Code in a containerised environment. This project provides a restricted sandbox environment for running Claude safely, preventing access to the local machine's file system and other sensitive resources. The containerized setup ensures that Claude operations are isolated from the host system, providing an additional layer of security for development and experimentation.

Quick Start

Start container runtime, e.g. Colima or Docker Desktop

Colima start
colima start

Build the image

docker build -t claude-sandbox .

Set up local directories and configuration

mkdir -p ~/.claude-sandbox/.claude
cp .claude.json ~/.claude-sandbox/.claude.json

Run the container

docker run -it \
  -v $(pwd):/workspace/${PWD##*/} \
  -v ~/.claude-sandbox/.claude:/home/appuser/.claude           \
  -v ~/.claude-sandbox/.claude.json:/home/appuser/.claude.json \
  --network="host"                \
  -w /workspace/${PWD##*/}        \
  claude-sandbox

This command starts the folder based on the project direct the container was started in so that you can use the same command for multiple projects and Claude will maintain separate configuration for each.

Set up shell alias go claude-box

bash alias

Add this to your ~/.bashrc or ~/.bash_profile:

alias claude-box='docker run -it  \
  -v $(pwd):/workspace/${PWD##*/} \
  -v ~/.claude-sandbox/.claude:/home/appuser/.claude \
  -v ~/.claude-sandbox/.claude.json:/home/appuser/.claude.json \
  --network="host"                \
  -w /workspace/${PWD##*/}        \
  claude-sandbox'

Then reload your shell configuration:

source ~/.bashrc
fish alias
function claude-box
    docker run -it \
        -v $(pwd):/workspace/(path basename $PWD)        \
        -v ~/.claude-sandbox/.claude:/home/appuser/.claude \
        -v ~/.claude-sandbox/.claude.json:/home/appuser/.claude.json \
        -w /workspace/(path basename $PWD)               \
        claude-sandbox $argv
end

You can register custom commands

mkdir ~/.claude-sandbox/.claude/commands
echo "Apply precepts.md from MCP Reader" > ~/.claude-sandbox/.claude/commands/precepts.md

Add you can add MCP Servers

claude-box mcp add -s user \
  --transport sse markdown-reader http://host.docker.internal:8080/sse
claude-box mcp add -s user \
  --transport http context7 https://mcp.context7.com/mcp

Development

Install pre-commit for local lint and pre-commit checks.

pip install pre-commit

Install the git hook scripts:

pre-commit install

Run against all files if you need to do a full check:

pre-commit run --all-files

Clean up

Remove the Docker image:

make clean

Remove image and all local directories. This will remove all session context and memory for Claude from running with this container.

make clean-all

About

Claude code sandboxed container

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages