DEV Community

Akash J
Akash J

Posted on

claude-docker: one command, one container, full permissions

Running Claude Code in a Sandboxed Docker Container

If you've ever wanted to run Claude Code with full permissions, without worrying about it touching anything outside your project. This one-liner install script does exactly that.

The script builds a minimal Docker image (node:22-slim) with Claude Code and the rtk CLI pre-installed, then wires up two shell aliases:

  • claude-docker — launches Claude Code inside the container with --dangerously-skip-permissions, your current directory mounted at /workspace
  • claude-docker-sh — drops you into a bash shell in the same container, useful for poking around or debugging

Because everything runs inside the container, "skip permissions" mode is much less risky than running it on your bare host — Claude can act freely, but it's boxed into the container's filesystem plus whatever you've explicitly mounted.

Under the hood, the install script just appends two docker run one-liners to your shell rc file as aliases — no separate binary, no PATH changes, just plain shell aliasing. That's what makes claude-docker and claude-docker-sh available as regular commands once the file is sourced.

The image itself starts from node:22-slim and installs git, curl, and gh via apt, then @anthropic-ai/claude-code via npm, plus the rtk CLI through its own install script. It also creates a dedicated non-root claudeuser to run as, rather than executing everything as root inside the container.

Install

Docker needs to be installed and running first — the script builds an image and everything else depends on that.

Two versions are available depending on your shell:

bash:

curl -s https://gist.githubusercontent.com/acashjos/93f47fce263dcaaa1cd5ba38b4459ffb/raw/5944ef120f150ca08287d406ff3397a6687b871f/claude-docker-install-bash.sh | sh
Enter fullscreen mode Exit fullscreen mode

zsh:

curl -s https://gist.githubusercontent.com/acashjos/93f47fce263dcaaa1cd5ba38b4459ffb/raw/5944ef120f150ca08287d406ff3397a6687b871f/claude-docker-install-zsh.sh | sh
Enter fullscreen mode Exit fullscreen mode

Or download it first, review it, then run:

curl -O https://gist.githubusercontent.com/acashjos/93f47fce263dcaaa1cd5ba38b4459ffb/raw/5944ef120f150ca08287d406ff3397a6687b871f/claude-docker-install-bash.sh
chmod +x claude-docker-install-bash.sh
./claude-docker-install-bash.sh
Enter fullscreen mode Exit fullscreen mode

The script builds the image, appends the aliases to your .bashrc (or .zshrc), and sources the file so they're available immediately.

Usage

From any project directory:

claude-docker
Enter fullscreen mode Exit fullscreen mode

This mounts your current working directory into the container and starts Claude Code with all permissions granted. On first run, use the /login command inside Claude Code to complete authentication.

Need a plain shell in the same environment instead?

claude-docker-sh
Enter fullscreen mode Exit fullscreen mode

Why containerize it

Running Claude Code with --dangerously-skip-permissions on a bare host means it can read, write, or execute anything your user account can. Wrapping it in Docker with only $HOME/.claude-docker and your project directory mounted keeps the blast radius contained to those two paths — a reasonable middle ground between full manual approval and full autonomy.

Full source and both shell variants: gist.github.com/acashjos/93f47fce263dcaaa1cd5ba38b4459ffb

Top comments (1)

Collapse
 
saheel_acharya_b1eac99389 profile image
Saheel Acharya

What's the benefit of containerizing a Claude code instance in this way?