Skip to content

Instantly share code, notes, and snippets.

@megahertz
Created February 16, 2026 10:36
Show Gist options
  • Select an option

  • Save megahertz/05627cbe4658b36bff16fac0e0c7d361 to your computer and use it in GitHub Desktop.

Select an option

Save megahertz/05627cbe4658b36bff16fac0e0c7d361 to your computer and use it in GitHub Desktop.
There's a `docker sandbox run gemini` 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:gemini'
case "$1" in
-h|--help)
echo 'Usage: docker-gemini [options] [command] [prompt]'
echo 'docker-gemini 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 gemini help:'
echo ''
set -- gemini --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 'Gemini CLI was updated'
set -- gemini --version
;;
cat|cp|ls|npm|pnpm|sh) ;;
*) set -- gemini --yolo "$@" ;;
esac
docker run --init -it --rm \
-v "$(pwd):$(pwd)" -w "$(pwd)" \
-v "${HOME}/.gemini:/home/agent/.gemini" \
-v "${HOME}/.gemini.json:/home/agent/.gemini.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