← Blog
Engineering

Gemini CLI sandbox: Docker, Seatbelt, YOLO mode and cloud

Yura Dubinin
Yura Dubinin

The Gemini CLI sandbox is off by default, and you turn it on with gemini -s, with GEMINI_SANDBOX=docker, or with "tools": {"sandbox": "docker"} in ~/.gemini/settings.json. On macOS it wraps the CLI in Seatbelt. With Docker or Podman it restarts the whole CLI inside a container that mounts your project folder and nothing else from your disk. Gemini CLI YOLO mode (--yolo, or --approval-mode yolo) is a separate switch that approves every tool call without asking. In our test of Gemini CLI 0.71.1 on 29 November 2026, YOLO mode did not start the sandbox, although Google's configuration reference says it does.

To let Gemini CLI work unattended without handing it your laptop, run it in a disposable VM. With Lizard Sandboxes that starts with one command:

lizard sandbox create -t base -s small

It boots a Firecracker microVM with its own kernel, 2 vCPU, 4 GB of RAM and a 20 GB disk for $0.0162 an hour, billed per second. The full steps are in Run Gemini CLI unattended in Lizard Sandboxes. We sell Lizard Sandboxes, so weigh that: for work at your own desk, the built-in sandbox is the right first step.

Everything below was checked against Gemini CLI 0.71.1, the latest tag on npm on 29 November 2026. Gemini CLI ships often and its flags move, so run gemini --version and gemini --help before you copy a command. What we tested lists what ran and what did not.

How do you enable the Gemini CLI sandbox?

Gemini CLI has three switches for the sandbox, and Google's sandbox docs list them in order of precedence:

SwitchExampleNotes
Command flaggemini -s -p "run the test suite"-s is short for --sandbox. It takes no value.
Environment variableexport GEMINI_SANDBOX=dockerAccepts true, docker, podman, sandbox-exec, runsc or lxc.
Settings file{"tools": {"sandbox": "docker"}}Goes in ~/.gemini/settings.json. true also works.

-s and GEMINI_SANDBOX=true let the CLI pick the backend. The 0.71.1 source checks for macOS Seatbelt first, then docker, then podman. gVisor (runsc) and LXC are never picked automatically; you name them.

We saw the flag win over the variable. On a Linux machine with Docker and no Podman, GEMINI_SANDBOX=podman gemini -p hi stopped with Missing sandbox command 'podman' (from GEMINI_SANDBOX), while GEMINI_SANDBOX=podman gemini -s -p hi started a Docker container.

Two details of the settings file cost us time:

  • The object form needs "enabled": true. Google's docs show {"tools": {"sandbox": {"command": "docker", "image": "..."}}}. With that exact shape in ~/.gemini/settings.json, 0.71.1 started no container. After we added "enabled": true, it did. The source reads config.enabled and treats a missing value as off.
  • Put the setting in your user file. {"tools": {"sandbox": "docker"}} in ~/.gemini/settings.json started a container. The same line in the project's .gemini/settings.json did not, even with the folder trusted through --skip-trust.

gemini --help in 0.71.1 lists no --sandbox-image flag. Older guides use it. Set the image with GEMINI_SANDBOX_IMAGE or the settings object instead.

To confirm that the sandbox is on, ask Docker:

docker events --filter event=start

Leave that running in a second terminal and start gemini -s. Once the image is pulled, a line with the sandbox image appears when the container starts.

What does each Gemini CLI sandbox backend isolate?

The backends differ most in what the agent can still read and whether it can reach the network. The descriptions below come from the sandbox docs and the 0.71.1 source; we ran only the Docker backend.

BackendRuns onFilesNetwork
macOS Seatbelt (sandbox-exec)macOSDefault profile permissive-open: writes confined to the project folder, reads allowed across the diskOpen by default; *-proxied profiles route it through a proxy
Docker or PodmanmacOS, Linux, WindowsContainer sees the project folder, mounted at the same absolute path, plus a sanitized copy of your settingsOpen by default
gVisor (runsc)LinuxSame mounts as Docker (docker run --runtime=runsc), with system calls handled by gVisor's user-space kernelSame as Docker
LXC/LXDLinux, experimentalA full system container you create and start yourself; the workspace is bind-mounted inSet by your container
Windows nativeWindowsSets a Low integrity level with icacls on the paths it may write to; the level stays on those files after the sessionNot covered in the docs section we read

macOS Seatbelt

On macOS, gemini -s uses Seatbelt even when Docker is installed, because the source checks for sandbox-exec first. The default profile is permissive-open. Its profile file starts from (deny default) and then allows file-read* everywhere, so the agent can still read ~/.ssh or ~/.aws; it cannot write outside the project. Six profiles ship with the CLI, chosen with SEATBELT_PROFILE: permissive-open, permissive-proxied, restrictive-open, restrictive-proxied, strict-open and strict-proxied. The two strict profiles restrict reads as well as writes. We did not run Seatbelt; we had no Mac in this test.

Docker and Podman

With Docker, Gemini CLI starts a container and runs itself again inside it. This is the command 0.71.1 built on our machine, copied from the process list (the project was /workspace/app):

docker run -i --rm --init --workdir /workspace/app \
  --add-host host.docker.internal:host-gateway \
  --volume /workspace/app:/workspace/app \
  --env HOME=/home/node \
  --volume /tmp/gemini-sandbox-ooMPNI:/home/node/.gemini:rw \
  --env GEMINI_API_KEY=... --env SANDBOX=sandbox-0.71.1-15ff2e99ce06 \
  us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.71.1 ...

What that tells you:

  • The project folder is the only part of your disk in the container. Everything else in it comes from the image.
  • ~/.gemini is replaced by a temporary folder. A comment in the source says the CLI does not mount the real ~/.gemini or credential files such as oauth_creds.json and .env, only a sanitized settings.json.
  • GEMINI_API_KEY is passed in. The agent's shell commands can read it.
  • There is no --network flag, so outbound network is open. A container we started from the same image with the same project mount returned HTTP 200 from https://example.com.
  • The container uses the host's kernel. uname -r printed the same version inside and outside (6.1.177+ on our Linux host).

The image is Debian 12 and runs as the user node (uid 1000). It includes Gemini CLI 0.71.1, git, Python 3, curl, ripgrep, jq and the GitHub CLI. Podman takes the same path with GEMINI_SANDBOX=podman; the docs add that rootless Podman gets --userns=keep-id so files keep your ownership. We did not run Podman.

To mount more than the project, set SANDBOX_MOUNTS to a comma-separated list of from:to:opts entries. Mounts are read-only unless you write rw:

export SANDBOX_MOUNTS="/path/on/host:/path/in/container:rw,/another/path:ro"

Tool sandboxing is a different setting

The settings schema in 0.71.1 calls tools.sandbox the "legacy full-process sandbox": the whole CLI moves into the container. A newer setting, security.toolSandboxing, isolates each tool call (a shell command, a file write) and leaves the CLI itself on the host. It is false by default in 0.71.1. With it on, the docs describe "sandbox expansion": when a command needs a path or network access the sandbox denies, Gemini CLI asks you to approve the wider access for that one run. We did not test tool sandboxing.

How do you run Gemini CLI in Docker with a custom image?

Point GEMINI_SANDBOX_IMAGE at an image that has bash and Gemini CLI in it. The default image in 0.71.1 is us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.71.1, set in the package's config.sandboxImageUri. (The docs page still names ghcr.io/google/gemini-cli:latest.) docker pull took 25 seconds on our Linux machine, and docker images reported a content size of 341 MB and 1.64 GB on disk.

An arbitrary image fails. With GEMINI_SANDBOX_IMAGE=node:22-alpine the run ended with:

[FATAL tini (6)] exec bash failed: No such file or directory

The container's start command is bash -c followed by $(which gemini), so the image needs both. The reliable route is to extend Google's image. This Dockerfile built in 25 seconds for us:

FROM us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.71.1
USER root
RUN apt-get update && apt-get install -y --no-install-recommends sqlite3 \
 && rm -rf /var/lib/apt/lists/*
USER node

The base image runs as node, so switch to root to install packages and back afterwards. Build it and use it:

docker build -t my-gemini-sandbox .
GEMINI_SANDBOX=docker GEMINI_SANDBOX_IMAGE=my-gemini-sandbox gemini -p "run the test suite"

docker events showed Gemini CLI starting my-gemini-sandbox, and sqlite3 was on the path inside it. For a permanent setup, put it in ~/.gemini/settings.json (note enabled):

{
  "tools": {
    "sandbox": {
      "enabled": true,
      "command": "docker",
      "image": "my-gemini-sandbox"
    }
  }
}

The docs also describe BUILD_SANDBOX=1 with a .gemini/sandbox.Dockerfile, which builds the image for you. Their troubleshooting section says this works only when you run Gemini CLI from a source checkout; an npm install needs a prebuilt image, as above. Extra docker run flags go in SANDBOX_FLAGS, for example --security-opt label=disable for Podman on SELinux.

What does Gemini CLI YOLO mode change?

Gemini CLI YOLO mode approves every tool call without asking. It is one of four approval modes, described this way in gemini --help:

ModeFlaggemini --help says
defaultnoneprompt for approval
auto_edit--approval-mode auto_editauto-approve edit tools
plan--approval-mode planread-only mode
yolo--yolo, -y or --approval-mode yoloauto-approve all tools

Five things to know before you use it:

  1. --yolo and --approval-mode do not combine. We got Cannot use both --yolo (-y) and --approval-mode together. Use --approval-mode=yolo instead. Google's CLI reference marks --yolo deprecated, so new scripts should use --approval-mode yolo.
  2. YOLO cannot be a saved default. general.defaultApprovalMode accepts default, auto_edit and plan; the configuration reference says YOLO "can only be enabled via command line".
  3. An untrusted folder cancels it. In a folder Gemini CLI does not trust, we saw Approval mode overridden to "default" because the current folder is not trusted, and the headless run then exited with code 55 and Gemini CLI is not running in a trusted directory. Pass --skip-trust or set GEMINI_CLI_TRUST_WORKSPACE=true for that run (trusted folders).
  4. The setting security.disableYoloMode blocks it, "even if enabled by a flag".
  5. YOLO mode did not turn the sandbox on in our test. The configuration reference says "Sandbox is enabled when using --yolo or --approval-mode=yolo by default." We ran both forms on Linux with Docker installed and watched docker events: no container started. gemini -s --approval-mode yolo started one. The file that decides whether to start the sandbox in 0.71.1, sandboxConfig.ts, does not read the approval mode.

So ask for both, every time:

gemini -s --approval-mode yolo -p "Run the tests and fix the first failing one."

Without -s, a YOLO run has your user's access: your home directory, your SSH keys and any cloud login in your shell. With -s and Docker it has the project folder, the API key and an open network, which is still enough to delete the project or post its contents somewhere. Commit before you start. The same trade-off exists in the other agents: see our guides to Claude Code's --dangerously-skip-permissions, the Codex sandbox and its --yolo flag and OpenCode permissions.

What are the common Gemini CLI sandbox errors?

These are the messages we hit in 0.71.1 and what cleared each one.

MessageCauseFix
Missing sandbox command 'podman' (from GEMINI_SANDBOX)The named backend is not installedInstall it, or set GEMINI_SANDBOX to one you have
Invalid sandbox command 'firejail'. Must be one of docker, podman, sandbox-exec, runsc, lxc, windows-nativeUnsupported valueUse one of the six listed
Sandbox image '...' is missing or could not be pulledWrong image name, or no access to the registryCheck GEMINI_SANDBOX_IMAGE and run docker pull by hand
[FATAL tini (6)] exec bash failedThe custom image has no bashBuild from Google's sandbox image
EACCES: permission denied, open '/home/node/.gemini/projects.json'The container runs as node (uid 1000) and the host user's files belong to another uidexport SANDBOX_SET_UID_GID=true
Gemini CLI is not running in a trusted directory (exit 55)Headless run in an untrusted folder--skip-trust or GEMINI_CLI_TRUST_WORKSPACE=true
Please set an Auth method ...No credentials in the environmentExport GEMINI_API_KEY
The run hangs after Debugger listening on ws://0.0.0.0:9229DEBUG=1 together with -sDrop DEBUG=1

Two of these need a note. We got the EACCES error running as root on Alpine Linux. Gemini CLI maps your uid into the container by itself on Debian, Ubuntu, NixOS, Arch, Fedora and SUSE (source); elsewhere, and in CI images that run as root, set SANDBOX_SET_UID_GID=true. With it, the same command got through to the API.

The docs suggest DEBUG=1 gemini -s for debugging. In our run that started Node inside the container with --inspect-brk=0.0.0.0:9229, which waits for a debugger to attach, so the command sat there until we killed it.

For scripts, the troubleshooting page documents exit code 44 for sandbox errors and 41 for authentication errors.

When does a cloud sandbox beat local Docker?

Local Docker is enough when you sit next to the run. A remote VM is better when the run should not share anything with your machine, or should not need your machine at all.

The Docker backend keeps the agent out of your home directory, but the container still runs on your laptop's kernel and network, and it ends when the laptop sleeps. A VM somewhere else holds only what you copy into it: one repository and one API key. If a YOLO run goes wrong there, you delete the VM.

Lizard Sandboxes are Firecracker microVMs, each with its own kernel. You create one with Lizard CLI, run commands in it and delete it. The run continues after you close the terminal. On the trial each sandbox lives for at most 1 hour; on a paid plan it lives as long as its --timeout.

How do you run Gemini CLI unattended in Lizard Sandboxes?

Create a Small sandbox from the base template, install Node.js and Gemini CLI with the package managers, pass GEMINI_API_KEY in the environment of one command, and start Gemini CLI in the background. We ran each command below with Lizard CLI 4.0.136.

You need Lizard CLI signed in to a project, jq, and a Gemini API key in your local shell as GEMINI_API_KEY.

Create the sandbox and install Gemini CLI

SB=$(lizard sandbox create -t base -s small --timeout 45m --json | jq -r .sandboxId)
lizard sandbox exec "$SB" -- apk add --no-cache nodejs npm
lizard sandbox exec "$SB" -- npm install -g @google/gemini-cli
lizard sandbox exec "$SB" -- gemini --version

Pass -s small and --timeout yourself. Outside the trial, a create with no size gives you a Medium sandbox at $0.0324 an hour, and a sandbox with no --timeout lives for 5 minutes. The base template is Alpine Linux 3.24 with git and Docker but without Node.js, which is why apk add comes first. It installed Node.js 24.22.3; the npm install took 8 to 10 seconds, and the last command printed 0.71.1.

Copy the project in

For a public repository, clone it:

lizard sandbox exec "$SB" -- git clone https://github.com/OWNER/REPO.git /workspace/app

Replace OWNER/REPO. For private code, send a git bundle with lizard sandbox files put so that no GitHub token enters the sandbox; our Claude Code sandbox guide has those three commands.

Start the run in the background

lizard sandbox exec "$SB" -- env GEMINI_API_KEY="$GEMINI_API_KEY" sh -c 'cd /workspace/app && nohup gemini --skip-trust --approval-mode yolo -p "Run the tests and fix the first failing one." > /tmp/gemini.log 2>&1 &'

Three choices in that line:

  • Your local shell expands "$GEMINI_API_KEY", and env sets it for this one process inside the sandbox. The key is not echoed and not written to a file. Do not echo it or run env on its own to check it. Processes the agent starts in the sandbox can read it, so use a key made for this job and delete it afterwards.
  • --skip-trust is required. A new folder is untrusted, and without the flag the headless run exits with code 55.
  • nohup ... & matters because lizard sandbox exec stops waiting after 150 seconds. A command that runs longer returns EXEC_TIMEOUT and carries on inside the sandbox, so start long jobs in the background and read the log.

We left out Gemini CLI's own -s here. The microVM is the boundary, and nothing of yours is in it apart from the repository and the key. If you want both layers, -s works in the base template because Docker is installed; the commands run as root, so add SANDBOX_SET_UID_GID=true.

Read the log, review the diff, delete the sandbox

lizard sandbox exec "$SB" -- tail -n 50 /tmp/gemini.log
lizard sandbox exec "$SB" -- git -C /workspace/app status --short
lizard sandbox exec "$SB" -- git -C /workspace/app diff
lizard sandbox rm "$SB" -y

Copy out what you want to keep before the last line: lizard sandbox files get "$SB" /workspace/app/calc.py ./calc.py.review downloads one file. lizard sandbox pause "$SB" is the alternative to deleting. A pause keeps the files and ends running processes, Gemini CLI included. A paused sandbox has no compute charge; its used disk is billed at $0.14 per GB-month until you resume or delete it.

What ran in our test and what did not

We had no Gemini API key for this test, so no model turn ran. We ran every command above with a placeholder key. Gemini CLI installed, started in the background, accepted the folder with --skip-trust and called the Gemini API, which answered API key not valid. Please pass a valid API key. (Status: 400). That line is what tail printed. git status and git diff ran and showed no changes, as expected. With a valid key, the log holds the agent's output instead.

Limits on the trial

New Lizard accounts start with a 7-day trial that requires a card and includes $5 of usage. On the trial you can run 1 Small sandbox at a time (plus 2 Mini), in US regions only, and every trial sandbox is deleted 1 hour after it starts at the latest. A --timeout above 1 hour is refused. The 45-minute run above fits. Runs longer than an hour, or several Small sandboxes side by side, need Lizard Pro: $19 a month with $19 of usage included.

What does a Gemini CLI run in Lizard Sandboxes cost?

A Small sandbox costs $0.0162 an hour, billed per second from create to delete, idle time included. The 45-minute sandbox above costs 0.75 × $0.0162 = $0.01215, a little over one cent. An 8-hour run, which needs a paid plan, costs 8 × $0.0162 = $0.13.

SizeCPU, memory, diskPer hour
Small2 vCPU, 4 GB, 20 GB$0.0162
Medium4 vCPU, 8 GB, 40 GB$0.0324
Large8 vCPU, 16 GB, 80 GB$0.0648

Rates are from the pricing page and the limits page on 29 November 2026. Usage counts against the $19 included in Lizard Pro, and anything above it is pay as you go at the same rates. Gemini API usage is billed by Google separately.

What we tested

On 29 November 2026 we tested Gemini CLI 0.71.1, installed from npm with Node.js 24.22.3, in Small sandboxes on Lizard (the base template: Alpine Linux 3.24, kernel 6.1, Docker Engine 29.10.0, commands running as root), using Lizard CLI 4.0.136. We deleted every sandbox afterwards.

What ran:

  • gemini --help and gemini --version.
  • The sandbox switches: -s, GEMINI_SANDBOX with valid, missing and invalid backends, and tools.sandbox in user and project settings as a string and as an object with and without enabled. We used docker events to see which runs started a container.
  • --yolo, --approval-mode yolo, both together, with and without --skip-trust, with and without -s.
  • The default image, an image without bash, a missing image and a custom image built from Google's.
  • Probes in a container started from the sandbox image with the same project mount: user, installed tools, an outbound request, the kernel version.
  • Every Lizard command in this article, including files get and pause on a test file.

What did not run:

  • Any model turn. We had no Gemini API key, so every Gemini CLI run ended at Google's API key not valid response. We did not watch Gemini CLI edit a file or run a shell command in any mode.
  • macOS Seatbelt, Podman, gVisor, LXC, the Windows native sandbox, tool sandboxing and BUILD_SANDBOX. Those sections come from Google's docs and the 0.71.1 source.
  • Google sign-in (OAuth) and Vertex AI authentication.

This is a record of one version on one setup, and it is our own test, so repeat the docker events check on your machine before you rely on it.

Which setup should you choose?

On a Mac, for interactive work, gemini -s with the default Seatbelt profile stops writes outside the project at almost no cost; move to a strict profile if the agent should not read your home directory.

On Linux, or when you want the agent to see only the project, use GEMINI_SANDBOX=docker and extend Google's image when you need more tools. Add --approval-mode yolo only together with -s, and check with docker events that a container really started.

For unattended YOLO runs, use a machine that holds nothing else. A Small sandbox on Lizard with one repository and one API key in it does that for $0.0162 an hour, and you delete it when the run ends.

Related guides: Claude Code sandbox: built-in isolation, Docker and cloud · Codex sandbox: modes, --yolo, Docker and cloud · OpenCode permissions, YOLO mode and Docker · Claude Code --dangerously-skip-permissions

Build with AI. Ship with Lizard

You don't need a platform team to go live. Your whole cloud, one CLI command away.

Start 7-day trial
Services
—
Add-ons
—
Deployments
—
Sandbox starts
—

We use cookies for essential site functionality and analytics. See our Cookie Policy.