31 tools· updated nov 2026

Gemini CLI sandbox: -s, GEMINI_SANDBOX, Seatbelt or Docker, and where the docs and the code disagree

Marek.

  • gemini-cli
  • coding-agents
  • agent-security

The Gemini CLI sandbox isolates shell commands and file edits from your host system, per the docs. You turn it on with -s, with the GEMINI_SANDBOX environment variable or with tools.sandbox in settings.json. On macOS a plain -s picks Seatbelt. On Linux and Windows it picks Docker, then Podman. I do not run Gemini CLI. Everything here comes from the docs and the v0.67.0 source, read on 5 November 2026.

gemini -s -p "run the test suite"
GEMINI_SANDBOX=docker gemini -p "build the project"
SEATBELT_PROFILE=strict-proxied gemini -s
{
  "tools": {
    "sandbox": "docker"
  }
}
  • Three switches. -s, GEMINI_SANDBOX, tools.sandbox. In the code -s turns the variable into true, so a named backend has to come from the variable alone.
  • macOS. Seatbelt with the permissive-open profile. Writes stay in the project. The network stays open.
  • Docker and Podman. Your project mounts at the same absolute path. GEMINI_SANDBOX_IMAGE swaps the image.
  • Windows. windows-native is a valid value in the code. The docs section about it is cut off.
  • How I know. Docs and code only. No session of my own.

Per the repository README, read on 5 November 2026, Gemini CLI was replaced by Antigravity CLI for unpaid tier and Google One users on 18 June 2026. This post covers Gemini CLI only.

My Claude Code sandbox post has the Claude Code side, and where my own test there stopped. This is the Gemini CLI side.

What is sandbox mode in Gemini CLI?

Sandbox mode relaunches Gemini CLI inside Seatbelt or a container. The configuration reference says sandboxing "is disabled by default". The sandbox page names three switches. One is the -s or --sandbox flag. One is GEMINI_SANDBOX. One is "sandbox" under tools in settings.json.

The docs list the flag first, "in order of precedence", and the v0.67.0 source keeps that order. The catch is that -s carries no backend name. With -s, config.ts sets GEMINI_SANDBOX to true before the backend is chosen. Then sandboxConfig.ts lets the variable take "precedence over argument (from command line or settings)". So GEMINI_SANDBOX=docker gemini -s loses the word docker and gets Seatbelt on a Mac. GEMINI_SANDBOX=docker gemini, without -s, gives Docker.

With a plain -s, the code looks for sandbox-exec on macOS first. Then docker. Then podman. If none is found, Gemini CLI stops with "GEMINI_SANDBOX is true but failed to determine command for sandbox". gVisor (runsc) and LXC are never picked on their own. You name them.

To check that you are inside, the docs suggest gemini -s -p "run shell command: env | grep SANDBOX".

How does the Gemini CLI sandbox work on macOS?

On macOS Gemini CLI wraps itself in Seatbelt through sandbox-exec. The default profile is permissive-open. Per the docs it confines writes to the project folder, plus a few others, and allows broad reads and network access. SEATBELT_PROFILE switches to one of six built-in profiles. The strict ones restrict reads too. The proxied ones send traffic through a proxy. A custom profile goes in .gemini/sandbox-macos-<name>.sb.

How do I set up the Gemini CLI sandbox with Docker?

Install Docker or Podman and start it. Then set GEMINI_SANDBOX=docker or "sandbox": "docker" under tools. The docs say your working directory mounts at "the exact same absolute path" inside the container. In the code the container starts with run -i --rm --init. It is removed when the session ends.

Two parts of the setup docs need care. The settings example for a custom image is an object with command and image. It has no enabled key. In loadSandboxConfig an object without enabled: true turns the sandbox off. I read the code that way. I have not run it. Add "enabled": true to be safe.

The other part is BUILD_SANDBOX=1 with .gemini/sandbox.Dockerfile. It builds a custom image only from a source checkout. The troubleshooting section and the configuration page both say so. With npm, build the image yourself. Then point GEMINI_SANDBOX_IMAGE at it.

Which Docker image does the Gemini CLI sandbox use?

The sandbox page says ghcr.io/google/gemini-cli:latest. The configuration page says "a pre-built gemini-cli-sandbox Docker image". In v0.67.0, packages/cli/package.json sets sandboxImageUri to us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.67.0. That value is the last fallback in the code. I pulled none of them.

The order in sandboxConfig.ts is GEMINI_SANDBOX_IMAGE, then GEMINI_SANDBOX_IMAGE_DEFAULT, then image from settings, then the package value. The name check allows only letters, digits and _.:/-. So a digest reference with @sha256: fails as "Invalid sandbox image name", per my reading.

Is there a Windows sandbox in Gemini CLI?

Yes, in the code. tools.sandbox accepts windows-native. On any other system sandboxConfig.ts rejects it with "Windows native sandboxing is only supported on Windows". A plain -s on Windows never picks it. It looks for Docker or Podman.

The Windows section of the docs starts with a literal "..." on geminicli.com and in docs/cli/sandbox.md. What is left covers side effects. The sandbox uses icacls to set a "Low Mandatory Level" on paths it writes to. That level stays after the session. The docs give icacls "C:\path\to\dir" /setintegritylevel Medium as the reset.

WindowsSandboxManager.ts describes Restricted Tokens, Job Objects and Low Integrity levels. I could not follow windows-native through the launch code. I treat Windows as the least documented path.

What is tool sandboxing in Gemini CLI?

Tool sandboxing isolates single tool calls instead of the whole process. The setting is security.toolSandboxing in settings.json. The configuration reference and the settings schema give it a default of false. The sandbox page explains how to turn it off, as if it were on. Set it on purpose, then restart.

In the v0.67.0 core code it uses sandbox-exec on macOS and Bubblewrap with seccomp on Linux. The default policy file keeps the network off in the plan, default and accepting_edits modes. In YOLO mode the macOS and Linux managers open workspace writes and the network. The tools.sandbox description calls the full-process sandbox "Legacy".

How does the Gemini CLI sandbox differ from the Claude Code sandbox?

Gemini CLI boxes the whole process when you ask for a sandbox. Claude Code and Codex box shell commands. Gemini CLI also leaves the network open on macOS by default. The other two columns come from my earlier posts, including Codex sandbox. Copilot CLI boxes shell commands too, see Copilot CLI sandbox.

Gemini CLI 0.67.0Claude CodeCodex CLI 0.166.0
Switch-s, GEMINI_SANDBOX, tools.sandboxsandbox.enabled in settings-s or sandbox_mode
What is boxedThe whole CLI, or single tools with toolSandboxingShell commandsShell commands
macOSSeatbelt, six profilesSeatbeltSeatbelt via sandbox-exec
LinuxDocker, Podman, gVisor or LXCbubblewrapbwrap plus seccomp
Native Windowswindows-native, docs cut offCommands run unsandboxedmxc, elevated, unelevated
Network defaultOpen in permissive-openProxy, allowedDomains start emptyOff in workspace-write

Frequently asked questions

Does YOLO mode turn on the Gemini CLI sandbox?

The configuration page says "Sandbox is enabled when using --yolo or --approval-mode=yolo by default." I found no YOLO check in sandboxConfig.ts at v0.67.0. Pass -s yourself. The rest is in Gemini CLI YOLO mode.

How do I let the Gemini CLI sandbox see a folder outside the project?

Use SANDBOX_MOUNTS, for example /data/models:/data/models:ro. The from path must be absolute. Without an option the mount is read-only.

Why does Gemini CLI say "Operation not permitted" in the sandbox?

Per the troubleshooting section, the operation needed access outside the sandbox. The docs suggest a more permissive profile or an extra mount.

Did you test this?

No. Gemini CLI is not installed on my machine. I read the sandbox and configuration pages and the v0.67.0 source on 5 November 2026. Per the README, unpaid tier and Google One users now get Antigravity CLI. I did not check its sandbox.

The verdict

I would set GEMINI_SANDBOX to the exact backend and leave -s out. In the code -s resets the variable to true. On Docker, pin the image yourself. On Windows, wait for complete docs.

Sources, read on 5 November 2026: the Gemini CLI sandbox page, configuration reference and CLI reference, plus the README. Code from google-gemini/gemini-cli at tag v0.67.0, mainly packages/cli/src/config/sandboxConfig.ts, packages/cli/src/utils/sandbox.ts and the managers in packages/core/src/sandbox/. The Claude Code and Codex columns come from my earlier posts.