Run Claude Code in a containerized environment.
To make it seamless and compatible with your local hooks and config Docker will run with the same user directory as your local environment.
Disclaimer: This project was created for my personal use and everything in this repo was tested against my Linux setup. Things may not work for your setup out of the box.
make buildThis automatically detects your host UID, GID, username, and timezone so the container matches your local environment. You can override any of these:
make build IMAGE=my-claude TAG=v1.0 TZ=America/New_Yorkdocker run -it --rm \
-v "$HOME/.claude:/home/$(whoami)/.claude" \
-v "$HOME/.claude.json:/home/$(whoami)/.claude.json" \
-v "$HOME/.gitconfig:/home/$(whoami)/.gitconfig:ro" \
-v "$HOME/.ssh:/home/$(whoami)/.ssh:ro" \
-v "$SSH_AUTH_SOCK:/tmp/ssh-agent.sock" \
-e SSH_AUTH_SOCK=/tmp/ssh-agent.sock \
-v "$HOME/.config/rtk:/home/$(whoami)/.config/rtk" \
-v "$HOME/.local/share/rtk:/home/$(whoami)/.local/share/rtk" \
-v "$(pwd):/work" \
-w /work \
claude-codeThis mounts your Claude credentials, Git config, SSH keys, and RTK config into the container and opens Claude Code in the current directory.
The container includes rtk, a CLI proxy that reduces token usage by 60-90% on common dev operations.
See the RTK installation guide for full setup details.
Important: RTK relies on Claude Code hooks to intercept commands. You must install the hooks in your Claude Code settings for RTK to work inside the container. Since
~/.claudeis mounted from your host, configure the hooks on your host machine and they will be available inside the container automatically.
Add this to your ~/.bashrc or ~/.zshrc:
alias cclaude='docker run -it --rm \
-v "$HOME/.claude:/home/$(whoami)/.claude" \
-v "$HOME/.claude.json:/home/$(whoami)/.claude.json" \
-v "$HOME/.gitconfig:/home/$(whoami)/.gitconfig:ro" \
-v "$HOME/.ssh:/home/$(whoami)/.ssh:ro" \
-v "$SSH_AUTH_SOCK:/tmp/ssh-agent.sock" \
-e SSH_AUTH_SOCK=/tmp/ssh-agent.sock \
-v "$HOME/.config/rtk:/home/$(whoami)/.config/rtk" \
-v "$HOME/.local/share/rtk:/home/$(whoami)/.local/share/rtk" \
-v "$(pwd):/work" \
-w /work \
claude-code'Then run from any project directory:
cclaude