Standalone containerized workflow for running OpenAI Codex CLI.
It provides a simple wrapper CLI with practical setup defaults:
- isolated Docker runtime
- current project mounted at
/workspace - persistent agent home on host
- optional conda mounts
- optional GPU access
- host/port access (
--network hostby default on Linux)
Required:
- Docker (or Podman)
- Codex authentication on host (
codex login) OR API key login inside container
Optional:
- NVIDIA runtime for GPU (
--gpus all) - Conda paths in
.env
# 1) Enter project
cd codex-docker
# 2) One-time setup
cp .env.example .env
./src/install.sh
# 3) Reload shell so alias is available
source ~/.bashrc # or your shell rc
# 4) Run from any project directory
cd ~/your-project
codex-dockercodex-docker # Start Codex in current directory
codex-docker --podman # Use podman instead of docker
codex-docker --continue # Resume previous Codex session
codex-docker --rebuild # Force rebuild image
codex-docker --rebuild --no-cache # Rebuild without cache
codex-docker --memory 8g # Set container memory limit
codex-docker --gpus all # Enable GPU access
codex-docker --cc-version 0.98.0 # Pin Codex CLI version (legacy alias)
codex-docker --codex-version 0.98.0Notes:
- Use
--codex-versionto pin the Codex CLI version.--cc-versionis a preserved legacy alias. - Inside container, Codex runs in YOLO mode via
--dangerously-bypass-approvals-and-sandbox.
- Current directory is mounted to
/workspace. - Persistent Codex home is mounted at
/home/codex-user/.codexfrom:${CODEX_DOCKER_HOME:-~/.codex-docker}/codex-home
- Default user-level agent instructions are seeded at:
${CODEX_DOCKER_HOME:-~/.codex-docker}/codex-home/AGENTS.md
- SSH keys are mounted from:
${CODEX_DOCKER_HOME:-~/.codex-docker}/ssh
host.docker.internalis always added.- On Linux, network mode defaults to
hostunless overridden in.env.
Set in .env:
CONDA_PREFIX=/path/to/miniconda3
CONDA_EXTRA_DIRS="/path/to/envs /path/to/pkgs"codex-docker mounts these paths read-only and exports CONDA_ENVS_DIRS/CONDA_PKGS_DIRS automatically when possible.
SYSTEM_PACKAGES="..."additional apt packages in image buildDOCKER_MEMORY_LIMIT=8gDOCKER_GPU_ACCESS=allDOCKER_NETWORK_MODE=hostTWILIO_*and other MCP-related credentials
mcp-servers.txt now uses codex mcp add ... commands.
- MCP installation runs once at first container startup and writes into persistent
~/.codexmount. - Default MCP servers configured in this repo:
serena(coding agent toolkit)context7(up-to-date docs in MCP format)twilio(SMS notifications; installed only whenTWILIO_*env vars are set)grep(GitHub code search viagrep-mcp: https://github.com/galprz/grep-mcp)
- Optional MCP server available but commented out by default:
zen(requiresOPENROUTER_API_KEY)
- To force reinstall:
FORCE_MCP_REINSTALL=1 codex-dockerSee MCP_SERVERS.md for details.
Preferred:
- Log in on host once:
codex login - Installer copies host
~/.codex/auth.jsoninto persistent codex-docker home
Alternative inside container:
codex login
# or
printenv OPENAI_API_KEY | codex login --with-api-key