gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Build docker sandbox fails (macOS)

Open floleuerer opened this issue 1 year ago • 11 comments

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

floleuerer avatar Jul 06 '25 18:07 floleuerer

Same issue here. I have a sandbox.Dockerfile inside my .gemini folder

Danielratmiroff avatar Jul 14 '25 06:07 Danielratmiroff

Same issue, with and without sandbox.Dockerfile

gabe-engineers avatar Jul 20 '25 01:07 gabe-engineers

Same problem with .gemini/sandbox.Dockerfile on Linux (NixOS).

thorstenweber83 avatar Jul 21 '25 21:07 thorstenweber83

Same here, macOS with .gemini/sandbox.Dockerfile

arnorhs avatar Aug 13 '25 15:08 arnorhs

Same here, WSL with .gemini/sandbox.Dockerfile

Image

christopherwoodall avatar Oct 19 '25 02:10 christopherwoodall

Same here on Ubuntu.

jholland1 avatar Oct 22 '25 20:10 jholland1

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.

Image

christopherwoodall avatar Oct 23 '25 13:10 christopherwoodall

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):

  1. Build the image manually using your local Dockerfile
docker build -t my-custom-sandbox -f .gemini/sandbox.Dockerfile .
  1. Invoke Gemini CLI with the environment variable
GEMINI_SANDBOX_IMAGE="my-custom-sandbox" gemini -s

s30122 avatar Feb 06 '26 02:02 s30122

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!

gemini-cli[bot] avatar May 04 '26 23:05 gemini-cli[bot]

Assigned area/agent based on content keywords. Marked as kind/bug with priority/p2.

gemini-cli[bot] avatar May 09 '26 20:05 gemini-cli[bot]

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!

gemini-cli[bot] avatar May 21 '26 02:05 gemini-cli[bot]