claudejail
v2.4.4
Published
CLI to manage Claude Code containers
Readme
claudejail
Run Claude Code inside a Docker container with your project mounted at /code. The image is built locally from a bundled Dockerfile based on the latest official debian image, with a non-root claude user and Homebrew installed at /home/linuxbrew/.linuxbrew (outside the user's home so a persistent volume can cover /home/claude without hiding brew). Anything written to /home/claude persists across sessions in a named volume.
Requirements
Install
npm i -g claudejail
# or
bun add -g claudejailUsage
claudejail [options]Mounts the current directory at /code, builds the image if needed, and drops you into Claude Code (or a shell with --shell).
Options
| Option | Description |
|---|---|
| --packages <pkg...> | Extra brew packages to install before launching (e.g. --packages ripgrep git) |
| --from <dir> | Host folder to mount at /code (default: current directory) |
| --prompt <text> | Custom system prompt passed to Claude Code |
| --volume <name> | Name of the persistent volume mounted at /home/claude (default: claudejail) |
| --networks <net...> | Docker networks to attach |
| --shell | Drop into an interactive shell instead of launching Claude Code |
Examples
# Launch Claude Code on the current directory
claudejail
# Open a shell in the same container instead
claudejail --shell
# Mount a specific project
claudejail --from /path/to/project
# Pre-install extra tools
claudejail --packages ripgrep fd jq
# Custom system prompt
claudejail --prompt "You are a Python refactoring assistant."How it works
- Image: built locally from a bundled
Dockerfile(debian:latest+claudeuser at/home/claude+ Homebrew at/home/linuxbrew/.linuxbrew). The tag is content-addressed, so the image rebuilds only when the Dockerfile changes; Docker's layer cache handles the rest. - Volumes:
<host dir>:/code— your project, bind-mounted read/write.claudejail:/home/claude— claude user home, persisted in a named Docker volume. Holds Claude Code auth (.claude/.credentials.json) and anything else written under/home/claude.
- Brew location:
/home/linuxbrew/.linuxbrew(baked into the image, not in the volume).claude-code,uv,bun, and any extra--packagesare installed at container start withbrew install. - Sudo: not used. The
claudeuser is created first and/home/linuxbrewis pre-chowned to it, theninstall.shruns asclaude. With no/usr/bin/sudopresent,have_sudo_accessreturns 1 andexecute_sudofalls back to plain exec — every chown/chgrp/mkdir touches the prefix we already own, so the install completes without root or sudoers. - PATH:
brew shellenvis dropped into/etc/profile.d/homebrew.shso brew is in PATH regardless of which user lands in the container, and the runtime volume on/home/claudecannot hide it. - Auth: stored in
/home/claude/.claude/.credentials.json. Lives in the named volume, so you log in once and stay logged in. - Permissions: Claude Code runs with
--dangerously-skip-permissions— the container is the sandbox.
