Skip to content

claude-box v2: Host-native Claude Code with Docker shell proxy#4

Open
ravaan wants to merge 7 commits into
masterfrom
claude-box-v2-host-proxy
Open

claude-box v2: Host-native Claude Code with Docker shell proxy#4
ravaan wants to merge 7 commits into
masterfrom
claude-box-v2-host-proxy

Conversation

@ravaan

@ravaan ravaan commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Inverts the architecture: Claude Code now runs natively on the host (enabling clipboard / Alt+V image paste), while shell commands are proxied to the Docker container via CLAUDE_CODE_SHELL_PREFIX + docker exec
  • Removes Claude Code CLI from the Docker image (smaller, faster builds) — it runs on the host via npx @anthropic-ai/claude-code
  • Adds generate_proxy_script() that handles command chain parsing, CWD translation between host↔container paths, and exit code forwarding

Test plan

  • claude-box build — rebuild image without Claude Code CLI
  • claude-box in a project dir — verify Claude Code launches on host
  • Run uname -a inside Claude Code — should show Linux (proves shell proxy works)
  • Alt+V paste a clipboard image — should work natively
  • Run cd subdir && pwd — verify CWD tracking across commands
  • claude-box shell — direct container bash still works

🤖 Generated with Claude Code

ravaan and others added 7 commits March 3, 2026 01:05
Inverts the architecture so Claude Code runs natively on the host
(enabling clipboard/Alt+V image paste) while shell commands are
proxied to the Docker container via CLAUDE_CODE_SHELL_PREFIX.

- Add generate_proxy_script() for command proxying via docker exec
- Modify launch() to use npx @anthropic-ai/claude-code on host
- Remove Claude Code CLI from Dockerfile (runs on host now)
- Add npx preflight check
- Rewrite README for v2 architecture

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The proxy script's sed commands used | as a delimiter, but the
patterns contain || (bash OR) and >| (force-overwrite), which
broke sed parsing. Switch to # as the delimiter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Piping commands via `printf | docker exec -i bash` produced no
output on Windows/Docker Desktop. Switch to `bash -c "$CMD"` which
passes the command as an argument instead of via stdin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Node.js on Windows can't spawn bash scripts directly — it needs
a .cmd wrapper. Generate proxy.cmd alongside the bash proxy script
and use its Windows path as CLAUDE_CODE_SHELL_PREFIX.

Also adds debug logging to /tmp/claude-box-proxy.log for diagnosing
proxy issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Debug log revealed the real command format from Claude Code:
- No -c flag — command passed as positional args directly
- Preamble uses { shopt ... || setopt ... } not just shopt
- Paths use /c/Users/... format, not /tmp/...
- Includes \< /dev/null for stdin isolation
- CWD tracking path is not single-quoted

Updated proxy to handle all these correctly. Also strip the
\< /dev/null stdin redirect since Docker provides its own stdin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The sed $ anchor wasn't working correctly, causing the pwd tracking
to duplicate instead of replace. Switch to removing the entire
suffix and appending a clean replacement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Upgrade git to 2.48+ via ppa:git-core/ppa (for worktree.useRelativePaths)
- Set worktree.useRelativePaths=true in entrypoint.sh so .git files
  in worktrees use relative paths (work on both host and container)
- Document worktree support in README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant