-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add sandbox for running Claude Code in Docker #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
67f5117
feat: add sandbox for running Claude Code in Docker
vinodmut 0246f50
chore: update secrets baseline for sandbox
vinodmut d65d7bf
docs: fix sandbox README paths to work from repo root
vinodmut c91a15b
fix: run sandbox container as non-root user and harden installer
vinodmut 33d8281
Merge branch 'main' into sandbox
visahak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| FROM debian:bookworm-slim | ||
|
|
||
| # Install Linux utilities, Python, and jq | ||
| RUN apt-get update && apt-get install -y \ | ||
| # Basics & editors | ||
| bash coreutils findutils grep sed gawk less nano vim tree file which procps psmisc sudo \ | ||
| # Networking | ||
| curl wget ca-certificates iputils-ping dnsutils netcat-traditional iproute2 \ | ||
| # Git + archives | ||
| git unzip zip tar gzip bzip2 xz-utils \ | ||
| # Build tools | ||
| build-essential make \ | ||
| # Python | ||
| python3 python3-venv python3-pip \ | ||
| # JSON parsing | ||
| jq \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create non-root user | ||
| RUN groupadd sandbox && useradd -m -g sandbox sandbox \ | ||
| && mkdir -p /workspace && chown sandbox:sandbox /workspace | ||
|
|
||
| # Create Python venv and make it accessible to sandbox user | ||
| RUN python3 -m venv /opt/claude-venv \ | ||
| && /opt/claude-venv/bin/python -m pip install --upgrade pip \ | ||
| && chown -R sandbox:sandbox /opt/claude-venv | ||
|
|
||
| # Install Claude Code as sandbox user | ||
| USER sandbox | ||
| RUN curl -fsSL -o /tmp/install.sh https://claude.ai/install.sh \ | ||
| && bash /tmp/install.sh \ | ||
| && rm /tmp/install.sh | ||
|
|
||
| # Add venv + Claude to PATH | ||
| ENV HOME="/home/sandbox" | ||
| ENV PATH="/opt/claude-venv/bin:/home/sandbox/.local/bin:${PATH}" | ||
|
|
||
| WORKDIR /workspace | ||
|
|
||
| CMD ["bash"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Claude Code Sandbox | ||
|
|
||
| A Docker image for running Claude Code in a sandboxed Debian environment with Python and common Linux tools. | ||
|
|
||
| ## Build | ||
|
|
||
| From the repository root: | ||
|
|
||
| ```bash | ||
| docker build -t claude-sandbox sandbox/ | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ## Run | ||
|
|
||
| 1. Copy the sample env file and add your API key: | ||
|
|
||
| ```bash | ||
| cp sandbox/sample.env sandbox/myenv # edit sandbox/myenv and set your credentials. | ||
| ``` | ||
|
|
||
| 2. Run the container, mounting your project into `/workspace`: | ||
|
|
||
| ```bash | ||
| docker run --rm -it --env-file sandbox/myenv -v "$(pwd)":/workspace claude-sandbox | ||
| ``` | ||
|
|
||
| 3. Test that Claude Code is working: | ||
|
|
||
| ```bash | ||
| docker run --rm --env-file sandbox/myenv claude-sandbox claude -p "who are you" | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ANTHROPIC_API_KEY=sk-ant-xxxx |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.