Created
February 16, 2026 10:36
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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