codex · Docker Compose
Codex is OpenAI's coding agent CLI, packaged on the agentimg foundations. This page runs it on Docker Compose with copy-paste examples; every file in this directory is shown below exactly as it exists in the repository.
See the tool overview for image variants, tags, and registries.
Requirements
- Docker or a compatible runtime
OPENAI_API_KEYset in your environment (never baked into the image)
Files in this directory
compose.sh
bash
#!/usr/bin/env bash
set -euo pipefail
case "${WORKSPACE:-}" in
/*) ;;
"") echo "Set WORKSPACE to an absolute host path." >&2; exit 2 ;;
*) echo "WORKSPACE must be an absolute host path: $WORKSPACE" >&2; exit 2 ;;
esac
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
cd "$script_dir"
exec docker compose "$@"docker-compose.yml
yaml
# WORKSPACE="$PWD" ./compose.sh run --rm codex
name: codex
services:
codex:
image: ${CODEX_IMAGE:-ghcr.io/hambn/codex:latest}
environment:
OPENAI_API_KEY: ${OPENAI_API_KEY:?set OPENAI_API_KEY}
volumes:
- ${WORKSPACE:?Set WORKSPACE to an absolute host path}:/workspace
stdin_open: true
tty: true
networks: [codex]
networks:
codex:
name: codexairgapped.docker-compose.yml
yaml
# WORKSPACE="$PWD" ./compose.sh -f airgapped.docker-compose.yml run --build --rm codex
name: codex-airgapped
services:
codex:
build:
context: ../../images/ubuntu-browser
image: local/codex:ubuntu-browser
pull_policy: never
environment:
OPENAI_API_KEY: ${OPENAI_API_KEY:?set OPENAI_API_KEY}
volumes:
- ${WORKSPACE:?Set WORKSPACE to an absolute host path}:/workspace
stdin_open: true
tty: true
networks: [codex]
networks:
codex:
name: codex-airgappedMore examples
Point the stack at a different workspace
bash
WORKSPACE=/srv/projects/my-app ./compose.sh run --rm codexUse a pinned image
bash
CODEX_IMAGE=ghcr.io/hambn/codex:<tag> ./compose.sh run --rm codex