content/manuals/ai/sandboxes/agents/gemini.md
{{< summary-bar feature_name="Docker Sandboxes" >}}
This guide covers authentication, configuration, and usage of Google Gemini in a sandboxed environment.
Official documentation: Gemini CLI
Create a sandbox and run Gemini for a project directory:
$ docker sandbox run gemini ~/my-project
The workspace parameter is optional and defaults to the current directory:
$ cd ~/my-project
$ docker sandbox run gemini
Gemini uses proxy-managed authentication. Docker Sandboxes intercepts API requests and injects credentials transparently. You provide your API key through environment variables on the host, and the sandbox handles credential management.
Set the GEMINI_API_KEY or GOOGLE_API_KEY environment variable in your
shell configuration file.
Docker Sandboxes use a daemon process that doesn't inherit environment variables from your current shell session. To make your API key available to sandboxes, set it globally in your shell configuration file.
Add the API key to your shell configuration file:
export GEMINI_API_KEY=AIzaSyxxxxx
Or use GOOGLE_API_KEY:
export GOOGLE_API_KEY=AIzaSyxxxxx
Apply the changes:
source ~/.bashrc (or ~/.zshrc)$ docker sandbox create gemini ~/project
$ docker sandbox run <sandbox-name>
The sandbox detects the environment variable and uses it automatically.
If neither GEMINI_API_KEY nor GOOGLE_API_KEY is set, Gemini prompts you to
sign in when it starts.
When using interactive authentication:
To avoid repeated authentication, set the GEMINI_API_KEY or GOOGLE_API_KEY environment variable.
Configure Gemini behavior in ~/.gemini/settings.json:
{
"disable_sandbox_tool": true,
"trusted_folders": ["/workspace"]
}
These settings disable safety checks and allow Gemini to operate without repeated confirmations for workspace files.
Pass Gemini CLI options after the sandbox name and a -- separator:
$ docker sandbox run <sandbox-name> -- --yolo
The --yolo flag disables approval prompts for a single session without
modifying the configuration file.
Template: docker/sandbox-templates:gemini
Gemini is configured to disable its built-in OAuth flow. Authentication is managed through the Docker Sandbox proxy with API keys.
See Custom templates to build your own agent images.