Claude Code has a --dangerously-skip-permissions flag (lovingly called “YOLO mode”) that lets it run shell commands without asking you first. The name sounds like it came out of a meeting with the legal team, and the legal team lost.
I wanted Claude to stop asking me before every ls. I did not want to give root-equivalent access to something that might decide my dotfiles are in the way. So: Docker.
Attempt 1: Docker’s official sandbox
Docker and Anthropic have a partnership, docker sandbox run claude. It’s secure and officially supported, but you can’t mount your own ~/.claude. So no custom config, no history and no CLAUDE.md.
Fine if you use it once in a while. Not for me.
Attempt 2: The one-liner
docker run -it --rm -v "$PWD":/app -w /app node:22 \
npx @anthropic-ai/claude-code --dangerously-skip-permissions
It works. It’s also painfully slow, because every run downloads and installs Claude from scratch. It also made me log in again every time I rebuilt the container. Not something I want to reach for 30 times a day.
Attempt 3: Bun
bun x should be faster than npx, so:
docker run -it --rm -v "$PWD":/app -w /app oven/bun \
bun x @anthropic-ai/claude-code --dangerously-skip-permissions
Three problems:
- Running as root? Claude refuses with
Cannot run as root. - Running as the
bunuser?EACCESerrors when installing packages. - Mounting my credentials from the host? UID mismatch (1000 vs 501), so it can’t read them.
So I needed to run as root and somehow convince Claude that’s okay.
Attempt 3.5: IS_SANDBOX=1
Turns out there’s an environment variable, IS_SANDBOX=1, that skips the root check.
docker run -it --rm -e IS_SANDBOX=1 -v "$PWD":/app -w /app oven/bun \
bun x @anthropic-ai/claude-code --dangerously-skip-permissions
New error:
Command not found: git
The Bun image is tiny and doesn’t ship git, and Claude really wants git to figure out the repo status. Time for a custom image.
Attempt 4: A custom Dockerfile
FROM oven/bun:latest
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
RUN bun add -g @anthropic-ai/claude-code
ENV IS_SANDBOX=1
ENTRYPOINT ["claude"]
Build it:
docker build -t claude-pro .
Run it:
docker run -it --rm -v "$PWD":/app -w /app claude-pro --dangerously-skip-permissions
It works! But Claude was using grep, find and cat for everything. They’re fine, but the output is noisy and that burns tokens.
Better tools
ripgrep instead of grep, fd instead of find, bat instead of cat, and jq for JSON:
FROM oven/bun:latest
RUN apt-get update && apt-get install -y \
git \
ripgrep \
fd-find \
bat \
jq \
&& rm -rf /var/lib/apt/lists/*
# Debian names these differently
RUN ln -s $(which fdfind) /usr/local/bin/fd && \
ln -s $(which batcat) /usr/local/bin/bat
RUN bun add -g @anthropic-ai/claude-code
ENV IS_SANDBOX=1
ENTRYPOINT ["claude"]
I also tried adding eza, gh and a few others. Those need third-party repos and GPG keys, and the build kept failing on signing errors. I gave up and stuck to what’s in the Debian repos.
Colours
The terminal looked washed out, with blocky gradients everywhere. Node inside Docker doesn’t believe your terminal supports true colour. The fix:
ENV FORCE_COLOR=3
ENV TERM=xterm-256color
Purely cosmetic, but it was bugging me.
The login loop
Mounting ~/.claude from the host with -v ~/.claude:/root/.claude was flaky. Claude’s config moved from a single file to a whole directory at some point, and the container kept asking me to log in every session.
What finally worked was a named volume:
docker volume create claude-auth
and pointing Claude at it:
docker run -it --rm \
-v "$PWD":/app \
-v claude-auth:/claude-config \
-e CLAUDE_CONFIG_DIR=/claude-config \
-w /app \
claude-pro --dangerously-skip-permissions
Log in once and it sticks, since the volume has nothing to do with the host filesystem.
Final setup
The Dockerfile:
FROM oven/bun:latest
RUN apt-get update && apt-get install -y \
git \
ripgrep \
fd-find \
bat \
jq \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s $(which fdfind) /usr/local/bin/fd && \
ln -s $(which batcat) /usr/local/bin/bat
RUN bun add -g @anthropic-ai/claude-code
ENV IS_SANDBOX=1
ENV FORCE_COLOR=3
ENV TERM=xterm-256color
ENTRYPOINT ["claude"]
The volume:
docker volume create claude-auth
The alias:
alias cy='docker run -it --rm \
--network host \
-v "$PWD":/app \
-v claude-auth:/claude-config \
-e CLAUDE_CONFIG_DIR=/claude-config \
-w /app \
claude-pro --dangerously-skip-permissions'
And a CLAUDE.md in the project root so it actually uses the new tools:
# Project Guidelines
When searching files, prefer `rg` over `grep` and `fd` over `find`.
Use `bat` for viewing files with syntax highlighting.
Use `jq` for JSON manipulation.
Caveats
--network hostgives Claude full network access. If you want it locked down, drop that and map ports yourself.- Anything created inside the container is owned by root, so you might need a
chownafterwards. - When Claude Code ships a new version, rebuild the image with
docker build -t claude-pro . --no-cache.
Conclusion
Claude can rm -rf whatever it likes inside the container and my laptop doesn’t care. Starts instantly, remembers my login, and I haven’t seen a permission prompt in weeks.
cy is muscle memory now.
Please don’t bind-mount /.