Codex¶
Codex CLI for AI-assisted development directly inside workspace containers.
To enable Codex CLI, set the CODEX argument to YES in the compose.yaml file of your desired workspace (e.g., template_ws/docker/compose.yaml). After making these changes, rebuild the Docker image.
Installation¶
The module installs the Codex CLI (latest version) via npm during the Docker image build.
Usage¶
After building a workspace with Codex enabled, you can use the CLI inside the container:
# Start your workspace container
cd ~/ros2-essentials/template_ws/docker
docker compose up -d
docker exec -it ros2-template-ws bash
# Inside the container, verify Codex is installed
codex --version
# Login with device code authentication
codex login --device-auth
# Run Codex CLI
codex
The first time you run Codex, you'll be prompted to sign in with your ChatGPT account or an API key.
If you want to run Codex CLI to run continuously without asking for permissions, make sure to comment out privileged: true in the compose.yaml file and restart the container. Then run:
This is not the most secure way to run Codex CLI, but it's often good enough as it's inside a container.
Authentication¶
Codex caches login details locally at ~/.codex/auth.json. The default compose.yaml mounts <git_root_dir>/.env/.codex to /home/user/.codex so credentials can persist across containers.