A portable, containerized environment for running Claude Code from anywhere on your system
Because it just feels better with protection.
- π³ Fully containerized - No local installation required (except Docker)
- π Directory mounting - Automatically mounts your current working directory
- βοΈ Config preservation - Uses your existing
~/.claude.jsonconfiguration - πΎ Session persistence - Claude settings, history, and conversations persist across sessions; automatically resumes where you left off
- π οΈ Pre-configured - Includes Node.js, git, bash, and vim
- π§ Per-project customization - Add tools or auth logic per repo via
.claude-container/ - π Portable - Run from any directory with a single command
# Clone the repository
git clone <your-repo-url>
cd claude-container
# Run the installer
./install.sh
# Start using it from any directory
cd ~/my-project
claude-container- Docker Desktop (or Docker Engine)
ANTHROPIC_API_KEYset in your environment or~/.zshrc
Run the installer script which will handle everything for you:
./install.shThe installer will:
- Check if Docker is running
- Build the Docker image if needed
- Install the wrapper script (system-wide or user-local)
- Set up permissions automatically
Click to expand manual installation steps
docker build -f Dockerfile.utility -t claude-container:latest .Or use the justfile:
just buildSystem-wide (requires sudo):
sudo cp claude-container /usr/local/bin/
sudo chmod +x /usr/local/bin/claude-containerUser-local (no sudo):
mkdir -p ~/bin
cp claude-container ~/bin/
chmod +x ~/bin/claude-container
export PATH="$HOME/bin:$PATH" # Add to ~/.bashrc or ~/.zshrcclaude-container versionNavigate to any project directory and run:
claude-containerThis launches a Docker container with:
- Your current directory mounted at
/<dirname> - Your
~/.claude.jsonconfiguration loaded - Your Claude home (
~/.claude-container/claude-home/) mounted for session persistence - Claude Code CLI automatically started
Claude Code will start immediately, resuming your last conversation if one exists. When you're done, exit Claude Code and the container will be automatically removed.
To drop into a shell instead of starting Claude:
claude-container console| Flag | Description |
|---|---|
--no-docker-extension |
Skip .claude-container/Dockerfile and run the base claude-container:latest image directly |
--base-image <image> |
Use a fully custom local image instead of claude-container:latest, also skips .claude-container/Dockerfile |
Examples:
# Skip per-project Dockerfile customization
claude-container --no-docker-extension
# Use a completely different image
claude-container --base-image my-custom-image:latest
# Drop into a shell with a custom image
claude-container --base-image my-custom-image:latest consoleYou can customize the container on a per-repo basis by creating a .claude-container/ directory in your project.
Create a Dockerfile that extends the base image:
FROM claude-container:latest
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
golang-go python3 your-tool-here \
&& rm -rf /var/lib/apt/lists/*
USER claudeThe first FROM line must be FROM claude-container:latest. The project image is built automatically and cached β it only rebuilds when the Dockerfile changes or the base image is updated.
For repos that need non-standard credentials (e.g. AWS Bedrock, custom tokens), create an executable .claude-container/auth.sh that prints KEY=VALUE pairs to stdout:
#!/bin/bash
echo "MY_TOKEN=abc123"
echo "MY_REGION=us-east-1"chmod +x .claude-container/auth.shEach KEY=VALUE line is exported into the container's environment. Values never appear in docker inspect.
#!/bin/bash
PROFILE="my-sso-profile"
aws sso login --profile "$PROFILE" >&2
CREDS=$(aws configure export-credentials --profile "$PROFILE")
REGION=$(aws configure get region --profile "$PROFILE" 2>/dev/null || echo "us-east-1")
echo "AWS_ACCESS_KEY_ID=$(echo "$CREDS" | jq -r .AccessKeyId)"
echo "AWS_SECRET_ACCESS_KEY=$(echo "$CREDS" | jq -r .SecretAccessKey)"
echo "AWS_SESSION_TOKEN=$(echo "$CREDS" | jq -r .SessionToken)"
echo "AWS_DEFAULT_REGION=$REGION"
echo "CLAUDE_CODE_USE_BEDROCK=1"
echo "ANTHROPIC_DEFAULT_SONNET_MODEL=us.anthropic.claude-sonnet-4-6"Use the justfile:
just build # clean rebuild (--no-cache)
just rebuild # rebuild using layer cache (faster)
just clean # remove base image
just clean-all # remove base image + all project images
just info # show image detailsOr manually:
docker build --no-cache -f Dockerfile.utility -t claude-container:latest .Image not found error
Build the Docker image:
just build
# or
docker build -f Dockerfile.utility -t claude-container:latest .Docker is not running
Start Docker Desktop or your Docker daemon before running the container.
Shell crashes after trust prompt
Try rebuilding with the latest version:
just buildOr check your config file permissions:
chmod 644 ~/.claude.jsonProject Dockerfile fails to build
Ensure the first line is exactly:
FROM claude-container:latestAlso make sure the base image exists (docker image inspect claude-container:latest).
Project Dockerfile exists but tools are missing in the container
When ./claude-container runs, it will print Using project image: claude-container-proj-<name>:latest if your .claude-container/Dockerfile was detected. If you don't see this line, the project image was not picked up.
Common causes:
- Running a stale installed version of
claude-containerrather than the current./claude-containerfrom your repo β reinstall with./install.sh - The base image
claude-container:latestdoesn't exist β rebuild it withjust build
To force a project image rebuild, delete the cached image and rerun:
docker rmi claude-container-proj-$(basename "$PWD" | tr '[:upper:]' '[:lower:]'):latest
claude-containerauth.sh not running
Make sure the script is executable:
chmod +x .claude-container/auth.shPermission issues with files
Ensure your Docker daemon is configured to map your user ID correctly. This is usually automatic on Docker Desktop.
Run the automated uninstaller:
./uninstall.shOr manually:
# Remove the script
sudo rm /usr/local/bin/claude-container
# or
rm ~/bin/claude-container
# Remove the Docker image
docker rmi claude-container:latest
# Remove persisted Claude home
rm -rf ~/.claude-container/Use the release script to create new versions:
./release.sh 1.0.1This will:
- Validate the version format (semantic versioning)
- Update the version in
claude-container - Create a git commit and tag
- Prompt you to push changes
Push the release:
git push origin main --tagsContributions are welcome! Please feel free to submit a Pull Request.
MIT License - See LICENSE file for details
Built for use with Claude Code by Anthropic.