Last active
May 13, 2026 12:37
-
-
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-gemini' | |
| case "$1" in | |
| -h|--help) | |
| echo 'Usage: docker-gemini [options] [command] [prompt]' | |
| echo 'docker-gemini commands:' | |
| echo ' update [docker-build-flags] 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) | |
| shift | |
| docker build --pull "$@" -t "${image}" - <<EOF | |
| FROM node:24 | |
| RUN usermod -l agent -d /home/agent -m node && groupmod -n agent node | |
| RUN ln -sfn /home/agent /home/$(id -un) | |
| RUN npm i -g @google/gemini-cli pnpm | |
| USER agent | |
| WORKDIR /home/agent | |
| EOF | |
| echo 'Gemini CLI was updated' | |
| set -- gemini --version | |
| ;; | |
| cat|cp|ls|npm|pnpm|sh) ;; | |
| *) set -- gemini --yolo "$@" ;; | |
| esac | |
| if ! docker image inspect "${image}" >/dev/null 2>&1; then | |
| "$0" update | |
| fi | |
| docker run --init -it --rm \ | |
| -v "$(pwd):$(pwd)" -w "$(pwd)" \ | |
| -v "${HOME}/.gemini:/home/agent/.gemini" \ | |
| -v "${HOME}/.agents:/home/agent/.agents" \ | |
| -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