Run OpenAI Codex in Docker with your project and subscription auth mounted.
Image: sayem314/ai-agents:codex (full language stack)
- Docker installed and running.
- Sign in to Codex on your host once so
~/.codexexists.
Add to ~/.zshrc or ~/.bashrc:
alias codex='docker run -it --rm -w /workspace \
-v "$PWD:/workspace" \
-v "$HOME/.codex:/root/.codex" \
-v "$HOME/.config/codex:/root/.config/codex" \
sayem314/ai-agents:codex --sandbox danger-full-access'Then reload: source ~/.zshrc
cd ~/my-app
codex
codex --helpFirst run pulls the image if it is not cached locally.
| Flag / mount | Purpose |
|---|---|
-it --rm |
Interactive TTY, remove container on exit |
-w /workspace |
Working directory inside the container |
-v "$PWD:/workspace" |
Bind-mount current project |
~/.codex → /root/.codex |
Codex subscription auth |
~/.config/codex → /root/.config/codex |
Additional Codex config |
--sandbox danger-full-access |
Full tool access inside the container (Docker is the outer boundary) |
Pass this flag in your alias — the image does not add it for you.
Smaller images with one language stack. Same auth mounts; only the image tag changes.
| Alias | Image |
|---|---|
codex-node |
sayem314/ai-agents:codex-node |
codex-python |
sayem314/ai-agents:codex-python |
codex-go |
sayem314/ai-agents:codex-go |
codex-rust |
sayem314/ai-agents:codex-rust |
Example:
alias codex-node='docker run -it --rm -w /workspace \
-v "$PWD:/workspace" \
-v "$HOME/.codex:/root/.codex" \
-v "$HOME/.config/codex:/root/.config/codex" \
sayem314/ai-agents:codex-node --sandbox danger-full-access'See Images for what each language stack includes.
To push from inside the container, add:
-v "$HOME/.gitconfig:/root/.gitconfig:ro" \
-v "$HOME/.ssh:/root/.ssh:ro"Instead of subscription auth, pass an API key:
-e OPENAI_API_KEY \See Authentication.
Add :cached to volume mounts for faster bind mounts on Docker Desktop, e.g. -v "$PWD:/workspace:cached".