<h1 align="center">
<a href="https://prompts.chat">
A simple, secure, containerized sandbox for unleashing Claude Code with configurable network restrictions, persistent configuration, and comprehensive development tools.
Sign in to like and favorite skills
A simple, secure, containerized sandbox for unleashing Claude Code with configurable network restrictions, persistent configuration, and comprehensive development tools.
Claude Container provides a Docker-based sandbox environment that includes:
Claude Container offers three firewall modes to balance security and usability:
--allow-outgoing (Default)--strictADDITIONAL_ALLOWED_DOMAINS environment variable--no-firewallLanguages & Runtimes:
Version Control:
Databases:
Claude Tools:
Text & File Processing:
Code Quality:
System Monitoring:
Shell:
[claude-container] for easy identification# Clone to a persistent location git clone https://gitlab.com/edward.kirton/claude-container.git ~/claude-container # Add to your shell configuration (e.g., ~/.zshrc or ~/.bashrc) echo 'export PATH="$HOME/claude-container/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
Navigate to any project directory and start the container:
cd /path/to/your/project claude-container
On first run:
~/claude-container-home for persistent configurationInside the container, authenticate with Claude:
claude
This authentication only needs to be done once and persists across sessions.
The container includes convenient aliases for Claude tools:
claude - Main Claude CLI interface (aliased to claude --dangerously-skip-permissions)ccusage - Claude Code usage tracking tool (aliased to npx ccusage blocks --active)These aliases are available inside the container's Zsh shell environment.
From any project directory:
# Default mode (allow all HTTP/HTTPS outbound) claude-container # Strict mode (only allow specific domains) claude-container --strict # No firewall (allow all network traffic) claude-container --no-firewall
This will:
Claude Container uses an isolated home directory (
~/claude-container-home) for security, which means Claude Code sessions inside and outside the container maintain completely separate configurations:
Outside the container (host):
~/.claude/ (your regular home directory)Inside the container:
~/claude-container-home/.claude/Important implications:
/resume to continue a conversation started outside the container (or vice versa)Sharing configurations between environments: If you want to use the same custom commands or settings in both environments, you can manually copy them:
# Copy custom commands from host to container cp ~/.claude/commands/*.md ~/claude-container-home/.claude/commands/ # Copy hooks from host to container; scripts often require editing to work, particulary if OS differs. cp ~/.claude/hooks/*.sh ~/claude-container-home/.claude/hooks/
--allow-outgoing)Allows broad internet access for general development:
claude-container # Uses default mode claude-container --allow-outgoing # Explicit
--strict)Maximum security with only essential domains allowed:
claude-container --strict
--no-firewall)Completely unrestricted network access:
claude-container --no-firewall
Execute commands directly with any firewall mode:
claude-container ls -la claude-container --strict claude --help claude-container --no-firewall npm install
In strict mode, you can add additional allowed domains:
Permanent (recommended): Edit
docker/whitelist.txt and add domains (one per line):
echo "example.com" >> docker/whitelist.txt echo "api.example.com" >> docker/whitelist.txt claude-container --rebuild --strict
Temporary (current session only):
export ADDITIONAL_ALLOWED_DOMAINS="example.com api.example.com" claude-container --strict
Note: Custom domains are only used in
--strict mode. In --allow-outgoing and --no-firewall modes, all or most domains are already accessible.
To rebuild the container image (can be combined with firewall modes):
claude-container --rebuild claude-container --rebuild --strict claude-container --rebuild --no-firewall
Note: Rebuilding the container is safe and won't affect your:
~/claude-container-home/.claude.json)This means you can freely modify the Dockerfile to add new tools or update versions without needing to re-authenticate with Claude.
claude-container/ ├── bin/ │ └── claude-container # Launcher script ├── docker/ │ ├── Dockerfile # Container definition │ ├── init-firewall.sh # Firewall configuration │ └── whitelist.txt # Allowed domains for strict mode ├── LICENSE.md # MIT License └── README.md
~/claude-container-home/ ├── .claude/ # Claude configuration ├── .claude.json # Authentication tokens ├── .gitconfig # Git configuration ├── .ssh/ # SSH keys ├── .oh-my-zsh/ # Shell framework └── .zsh_history # Command history
Your project is mounted at the same path inside the container as on your host system. For example:
/Users/yourname/Projects/myapp/Users/yourname/Projects/myappThis ensures path references remain valid and tools like Git work seamlessly.
The
~/claude-container-home directory is mounted as your home inside the container, preserving:
chmod +x ~/claude-container/bin/claude-containerdocker logs <container-name>~/claude-container-home/.claude.json and re-authenticateapi.anthropic.comdocker logs <container-name> 2>&1 | grep BLOCKEDexport ADDITIONAL_ALLOWED_DOMAINS="domain.com"docker exec -it <container-name> sudo iptables -L -v -nclaude-container --allow-outgoing or claude-container --no-firewall--rebuild to see firewall configuration again--strict: Shows domain resolution and IP configuration--allow-outgoing: Shows HTTP/HTTPS rule configuration--no-firewall: Shows firewall disabled messagedocker exec -it --user root <container-name> bashThe container includes
uv, a fast Python package manager. However, Python virtual environments are platform-specific because compiled binaries and C extensions differ between operating systems and architectures.
If you run
uv sync in the container (Linux), the .venv directory will contain Linux binaries. After you exit the container, you'll need to run uv sync again on your host (macOS) before you can use uv run because:
.venv/bin/ directory contains platform-specific executables# Working on macOS host cd myproject uv sync # Creates/updates .venv with macOS binaries uv run python script.py # Works! Using macOS Python # Enter container to test in Linux environment claude-container uv sync # Re-creates .venv with Linux binaries uv run python script.py # Works! Using Linux Python exit # Back on macOS host uv run python script.py # ERROR! .venv contains Linux binaries uv sync # Re-sync for macOS uv run python script.py # Works again!
When
uv detects a platform change, it will:
.venv is for a different platformuv.lock file for consistency across platformsuv.lock file is platform-independent - it ensures the same package versions across all platforms.venv directory is platform-specific - always add it to .gitignoreUV_LINK_MODE=copy - this suppresses hardlink warnings caused by Docker filesystem boundariesuv sync after switching between host and container if they're different platformsuv.lock for reproducible installs - commit this file to version control.venv/ - it contains platform-specific binariesThis approach maintains both environments simultaneously, avoiding re-syncs when switching.# On macOS host UV_PROJECT_ENVIRONMENT=.venv-macos uv sync UV_PROJECT_ENVIRONMENT=.venv-macos uv run python script.py # In Linux container UV_PROJECT_ENVIRONMENT=.venv-linux uv sync UV_PROJECT_ENVIRONMENT=.venv-linux uv run python script.py
uv run ... inside the containerClaude Container does not include any preconfigured MCP services. You can add your own MCP servers in the usual way - your configuration will persist between sessions as it's stored in your persistent home directory (
~/claude-container-home).
To add an MCP server inside the container:
For HTTP-based MCP servers in strict mode: Add the domain to your firewall configuration by editing
docker/whitelist.txt and rebuilding:
# Outside the container: Add any required URLs to docker/whitelist.txt echo "mcp.context7.com" >> docker/whitelist.txt claude-container --rebuild --strict
Inside the container: Add the MCP server using the Claude CLI
# Example: Adding Context7 MCP server claude mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: YOUR_API_KEY"
Your MCP configuration will be saved to
~/.claude/mcp_settings.json and persist across container sessions.
For more information about MCP servers, see the Claude MCP documentation.
docker/ (e.g., to add new tools or change versions)claude-container --rebuildclaude-containerYour Claude authentication and all configuration in
~/claude-container-home persists across rebuilds.
Edit version variables at the top of
docker/Dockerfile:
ARG PYTHON_VERSION=3.13.7 ARG YAMLFMT_VERSION=v0.10.0 # etc...
Derived from Claude Code devcontainer. Written by Claude Code under the direction of Edward Kirton.
MIT License - See LICENSE file for details