Skip to content

Codex

GitHub code

Codex CLI for AI-assisted development directly inside workspace containers.

Last tested on commit d43ad1c by @j3soon.

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.

Notice - Subscription required: Codex is a third-party service that requires an active OpenAI account or subscription to use. This module only installs the CLI; you need an active subscription to use it.

Installation

The module installs the Codex CLI (latest version) via npm during the Docker image build.

Alternatively, if you want to install the Codex extension for your favorite IDE (e.g., Codex for VSCode), refer to the Codex IDE extension for more details instead. This module doesn't need to be enabled if you just want to use the IDE extension.

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:

codex --yolo

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.d/.codex to /home/user/.codex so credentials can persist across containers.

References