Build docker sandbox fails (macOS)
What happened?
I am trying to use a docker-sandbox with a custom Dockerfile (to install pip). Unfortunately gemini can not build the image. I tried installing nodejs / npm with brew and nvm - both approaches didn't work.
export GEMINI_SANDBOX=docker
export BUILD_SANDBOX=1
gemini
hopping into sandbox (command: docker) ...
ERROR: cannot build sandbox using installed gemini binary; run `npm link ./packages/cli` under gemini-cli repo to switch to linked binary.
I tried to run the command npm link ./packages/cli but still get the same error message.
What did you expect to happen?
gemini should build the docker image.
Client information
$ gemini /about
About Gemini CLI │
│ │
│ CLI Version 0.1.9 │
│ Git Commit 34935d6 │
│ Model gemini-2.5-pro │
│ Sandbox sandbox-exec (permissive-open) │
│ OS darwin │
│ Auth Method gemini-api-key
Login information
No response
Anything else we need to know?
No response
Same issue here. I have a sandbox.Dockerfile inside my .gemini folder
Same issue, with and without sandbox.Dockerfile
Same problem with .gemini/sandbox.Dockerfile on Linux (NixOS).
Same here, macOS with .gemini/sandbox.Dockerfile
Same here, WSL with .gemini/sandbox.Dockerfile
Same here on Ubuntu.
One work around I found was to build the image manually but name and tag it like it would be in the registry. So for gemini version 0.0.10 you would build an image like so:
DOCKERFILE_PATH=".gemini/sandbox.Dockerfile"
IMAGE_BASE_NAME="us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox"
IMAGE_TAG=$(gemini --version)
IMAGE_NAME="${IMAGE_BASE_NAME}:${IMAGE_TAG}"
docker build -t "${IMAGE_NAME}" -f "${SCRIPT_DIR}/${DOCKERFILE_PATH}" .
This builds a local image that gemini will detect and use.
EDIT: Looking into it, this appears to be intended behavior. If you want to use gemini to build the sandbox then you need to install from source.
In a non-development environment (where the CLI is installed as a package rather than run from the source), the BUILD_SANDBOX=1 feature is disabled by design.
To use a custom Docker image, you must manually build it and specify it via environment variables.
Recommended Workflow (Workaround):
- Build the image manually using your local Dockerfile
docker build -t my-custom-sandbox -f .gemini/sandbox.Dockerfile .
- Invoke Gemini CLI with the environment variable
GEMINI_SANDBOX_IMAGE="my-custom-sandbox" gemini -s
This item has been automatically marked as stale due to 60 days of inactivity. It will be closed in 14 days if no further activity occurs. Thank you!
Assigned area/agent based on content keywords. Marked as kind/bug with priority/p2.
This item has been closed due to 14 additional days of inactivity after being marked as stale. If you believe this is still relevant, feel free to comment or reopen. Thank you!