Run AI CLI tools (OpenAI Codex, Google Antigravity, Claude, OpenCode) inside Docker to keep your host clean while persisting CLI auth and config on your machine.
- Why AI CLI in Docker?: Rationale behind this project.
Dockerfile.codex: Based onghcr.io/openai/codex-universalwith@openai/codexpreinstalled.Dockerfile.antigravity: Based onubuntu:24.04with the Google Antigravity CLI preinstalled.Dockerfile.claude: Based onubuntu:24.04with@anthropic-ai/claude-codepreinstalled.Dockerfile.opencode: Based onubuntu:24.04withopencode-aipreinstalled.activate.sh: Bash/Zsh helper functions.ai-docker.sh: Interactive Bash TUI.activate.ps1: PowerShell helper functions for Windows.ai-docker.ps1: Interactive PowerShell menu for Windows.
- Docker installed and running.
- One of:
- Bash or Zsh (Linux/macOS).
- PowerShell 5.1+ or PowerShell 7+ (Windows).
-
Clone this repo and enter the directory.
-
Source the activation script:
source ./activate.sh- Launch the interactive TUI:
ai-docker- Or run helpers directly:
claude-docker-shellantigravity-docker-shellcodex-docker-shellopencode-docker-shell
-
Clone this repo and enter the directory in PowerShell.
-
Load helper functions into your current session:
. .\activate.ps1If script execution is blocked, run this first in the same terminal:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass- Launch the interactive menu:
ai-docker- Or run helpers directly:
claude-docker-shellantigravity-docker-shellcodex-docker-shellopencode-docker-shell
ai-docker: Launch interactive menu (Bash TUI or PowerShell menu).codex-docker-build/codex-docker-shellantigravity-docker-build/antigravity-docker-shellclaude-docker-build/claude-docker-shellopencode-docker-build/opencode-docker-shelldocker-ai-build-all: Build all images with no cache.codex-auth-docker-run: Run Codex auth flow inside container.ai-docker-deactivate: Remove helper functions from current shell.
- A tmux session named after your current folder (overridable with
TMUX_SESSION). - Windows:
- AI CLI (active by default): runs
codex,agy(Antigravity),claude, oropencode, then keeps shell open. - Shell
- Shell
htop
- AI CLI (active by default): runs
- Switch windows:
Ctrl-bthenn(next) /p(previous)Ctrl-bthen1/2/3/4to jump directlyCtrl-bthenwto choose from a list
- Create a new window:
Ctrl-bthenc - Rename current window:
Ctrl-bthen, - Close current window: type
exit, orCtrl-bthen& - Detach from tmux:
Ctrl-bthend - Re-attach inside container:
tmux attach - Extra binding:
Ctrl-bthenQprompts then kills all tmux sessions.
More tmux docs:
- https://github.com/tmux/tmux/wiki
man tmux
By default, tmux truncates the left status text. This setup increases the default status-left length to 60 characters and displays the active profile alongside the session name (e.g. workspace (default)).
- One-off run:
TMUX_STATUS_LEFT_LENGTH=80 antigravity-docker-shell - Persist for current shell session:
export TMUX_STATUS_LEFT_LENGTH=80
Add activation to your shell profile so helpers are available in new terminals.
Bash (~/.bashrc or ~/.bash_profile):
if [ -f "/absolute/path/to/ai-cli-in-docker/activate.sh" ]; then
. "/absolute/path/to/ai-cli-in-docker/activate.sh"
fiZsh (~/.zshrc):
if [ -f "/absolute/path/to/ai-cli-in-docker/activate.sh" ]; then
source "/absolute/path/to/ai-cli-in-docker/activate.sh"
fiPowerShell ($PROFILE):
if (!(Test-Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -Path $PROFILE -Value '. "C:\absolute\path\to\ai-cli-in-docker\activate.ps1"'Reload profile:
- Bash:
source ~/.bashrc - Zsh:
source ~/.zshrc - PowerShell:
. $PROFILE
The CLI supports multiple isolated profiles. Only default is pre-defined, but you can create additional profiles (e.g., personal, work). Each profile isolates auth, configs, recent workspace paths, and environment files under:
~/.ai-docker-profiles/<profile-name>/
Specifically, for the active profile:
- Codex:
- Host:
~/.ai-docker-profiles/<profile>/codex-docker-config - Container:
/root/.codex
- Host:
- Antigravity:
- Host:
~/.ai-docker-profiles/<profile>/antigravity-cli-docker-config - Container:
/root/.gemini
- Host:
- Claude:
- Host:
~/.ai-docker-profiles/<profile>/claude-docker-config - Container:
/root/.claude /root/.claude.jsonis symlinked to/root/.claude/claude.json
- Host:
- OpenCode:
- Host:
~/.ai-docker-profiles/<profile>/opencode-docker/local-> Container:/root/.local - Host:
~/.ai-docker-profiles/<profile>/opencode-docker/config-> Container:/root/.config/opencode - Host:
~/.ai-docker-profiles/<profile>/opencode-docker/docker-env.env-> Container environment variables
- Host:
Each host config directory includes a docker-env.env file that is passed to the container.
- Switching Profiles via TUI: Select
👤 Switch Active Profileon the main screen to change profiles or create a new one. - Environment Override: Set the
AI_DOCKER_PROFILEenvironment variable in your terminal session to override the active profile:export AI_DOCKER_PROFILE=work - Active Profile File: If
AI_DOCKER_PROFILEis not set, the active profile defaults to the name stored in~/.ai-docker-active-profile, and falls back todefaultif the file doesn't exist.
Add environment variables to the tool's docker-env.env file.
Example for Claude (~/.ai-docker-profiles/<profile>/claude-docker-config/docker-env.env):
ANTHROPIC_BASE_URL=http://host.docker.internal:1234
ANTHROPIC_AUTH_TOKEN=lm
ANTHROPIC_MODEL=mlx-community/qwen3.5-9bcodex-auth-docker-run may print a wrapped sign-in URL.
If your terminal cannot open it directly:
- Copy the full URL carefully.
- Remove line breaks/spaces in a text editor.
- Open the cleaned URL in your browser.
The project includes a comprehensive automated test suite. You can run it locally or let GitHub Actions run it in CI/CD.
You can execute the test suite locally using Docker. The host machine does not need Python, Pester, or other test tooling installed.
- On macOS/Linux:
chmod +x run-tests.sh ./run-tests.sh
- On Windows (PowerShell):
.\run-tests.ps1
Note: The PowerShell Pester test block is automatically skipped when running on ARM64/aarch64 hosts (such as Apple Silicon Mac machines) to prevent Docker/qemu architecture emulation issues.
On every push or pull request to the main or master branches, GitHub Actions automatically triggers the Test Suite workflow. This workflow:
- Runs Python-based Bash helper and TUI navigation tests.
- Runs PowerShell Pester helper tests.
- Builds and verifies all four AI CLI images (
claude,antigravity,codex,opencode) in parallel.
Use Ctrl+J to insert a line break.
Verified in:
antigravity cli (agy)codex cliopencode
- Rebuild after changing a Dockerfile:
codex-docker-build,antigravity-docker-build, etc. - Remove helper functions from current shell:
ai-docker-deactivate
- On Linux hosts,
codex-auth-docker-runuses--network=hostby default. - On Windows/macOS with Docker Desktop, host networking is disabled by default in
activate.ps1. - To force host networking in PowerShell helpers (only if your Docker setup supports it), set
AI_DOCKER_USE_HOST_NETWORK=1.