Skip to content

Instantly share code, notes, and snippets.

@megahertz
Last active February 16, 2026 10:34
Show Gist options
  • Select an option

  • Save megahertz/5d213f5e5ba4d4de7a95494621d8e734 to your computer and use it in GitHub Desktop.

Select an option

Save megahertz/5d213f5e5ba4d4de7a95494621d8e734 to your computer and use it in GitHub Desktop.
There's a `docker sandbox run claude` command, but it requires Docker Desktop to be installed, which is pretty undesirable on Linux since it replaces Docker Engine with a VM environment. This simple script does similar things.
#!/usr/bin/env bash
set -e
image='docker/sandbox-templates:claude-code'
case "$1" in
-h|--help)
echo 'Usage: docker-claude [options] [command] [prompt]'
echo 'docker-claude commands:'
echo ' update Pull latest image and update packages'
echo ''
echo ' cat Run the CMD in container'
echo ' cp ...'
echo ' ls ...'
echo ' npm ...'
echo ' pnpm ...'
echo ' sh ...'
echo ''
echo 'Original claude help:'
echo ''
set -- claude --help
;;
update)
docker pull "${image}"
cid=$(docker create "${image}" sh -c 'npm i -g pnpm')
docker start -a "${cid}"
docker commit "${cid}" "${image}"
docker rm "${cid}"
echo 'Claude code was updated'
set -- claude --version
;;
cat|cp|ls|npm|pnpm|sh) ;;
*) set -- claude --dangerously-skip-permissions "$@" ;;
esac
docker run --init -it --rm \
-v "$(pwd):$(pwd)" -w "$(pwd)" \
-v "${HOME}/.claude:/home/agent/.claude" \
-v "${HOME}/.claude.json:/home/agent/.claude.json" \
-e GIT_AUTHOR_NAME="$(git config user.name)" \
-e GIT_AUTHOR_EMAIL="$(git config user.email)" \
-e TERM=xterm-256color \
-e COLORTERM=truecolor \
"${image}" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment