Skip to content
arvm
Docs menu

Run Codex CLI in the cloud

Run OpenAI Codex CLI inside an isolated Ubuntu 24.04 VM with root, Docker, and a persistent 51 GB disk, either interactively over SSH or headlessly through arvm exec.

1. Create a VM and connect

Create a default machine (4 vCPUs, 8 GB RAM, 51 GB disk) and open a shell on it.

Terminal
$ arvm new --idle-timeout 2h
$ arvm ssh calm-river-otter

The examples below use calm-river-otter. Replace it with the name arvm new prints.

2. Install and sign in to Codex CLI

Node.js LTS is preinstalled on the ubuntu-24.04 image. Install Codex CLI and sign in inside the VM:

Terminal
dev@calm-river-otter:~$ npm install -g @openai/codex
dev@calm-river-otter:~$ codex login

For headless runs without browser sign-in, export OPENAI_API_KEY inside the VM or set it on the machine at creation with --env.

3. Run Codex interactively or headlessly

For an interactive session that survives SSH disconnects, start tmux (or Rex) and launch codex in your repository:

Terminal
dev@calm-river-otter:~$ git clone https://github.com/example/app.git
dev@calm-river-otter:~$ cd app
dev@calm-river-otter:~$ codex

To drive Codex headlessly from your laptop or a CI script without opening SSH, run codex exec through arvm exec:

Terminal
$ arvm exec calm-river-otter --cwd /home/dev/app --timeout 30m -- codex exec "Run the test suite and fix failing tests"

4. Copy patches or artifacts back and stop the VM

Pull generated diffs or logs back to your local machine with arvm cp, then stop the VM so billing ends while the disk stays intact:

Terminal
$ arvm cp calm-river-otter:/home/dev/app/changes.patch .
$ arvm stop calm-river-otter

When you are finished with the VM permanently, remove it with arvm rm calm-river-otter --yes.

Idle stop and billing

A default VM draws $0.018 an hour from your $20 monthly plan, $13.14 for a full month. A small VM (2 vCPUs, 4 GB RAM) draws $0.009 an hour ($6.57 for a full month), and a large VM (8 vCPUs, 16 GB RAM, 111 GB disk) draws $0.036 an hour ($26.28 for a full month). Stopped machines cost $0.

Idle stop shuts down a quiet VM after 60 minutes by default (or the duration passed to --idle-timeout). Both arvm ssh and arvm exec count as activity. See Idle stop and Billing.

Disks live on one drive with no automatic backups. Push commits to Git before stopping or deleting a machine.

Troubleshooting

Symptom What to do
arvm exec fails with machine_not_running Run arvm start calm-river-otter first. Unlike arvm ssh, arvm exec does not wake a stopped machine.
arvm exec cuts off stdout or stderr Each stream truncates at 8 MiB. Redirect verbose test output to a file inside the VM and download it with arvm cp.
Background process started inside arvm exec vanishes Processes left behind when arvm exec exits are killed. Use sudo systemd-run for background daemons: see Run a job that outlives the request.
codex cannot reach a local port from your laptop Forward the port privately with arvm forward calm-river-otter 8080 or expose it over HTTPS with arvm expose calm-river-otter 8080.