Skip to content

Quick start: Docker Compose

After this page you have Codex running on your machine and you are signed in as its first admin. It uses the published images and a standalone Compose file with the app, the worker and Postgres 18.

  1. Make a folder and download the two files into it.

    Terminal
    curl -LO https://github.com/codexsuite/docs/raw/main/examples/quickstart/docker-compose.yml
    curl -L https://github.com/codexsuite/docs/raw/main/examples/quickstart/.env.example -o .env

    The first file is the Compose file. The second becomes your .env.

  2. Open .env and set three values.

    • POSTGRES_PASSWORD is the database password. Use letters and digits only, because it goes into a connection string.
    • CODEX_ADMIN_EMAIL is the email you will sign in with.
    • CODEX_ADMIN_PASSWORD is your password. It needs at least 10 characters.

    Compose refuses to start if any of the three is empty. A password under 10 characters makes the app stop at startup.

  3. Start the stack.

    Terminal
    docker compose up -d

    Compose pulls the images, starts Postgres, and then starts the app and the worker. The app applies the database migrations when it starts.

  4. Check that the app is up.

    Terminal
    curl http://localhost:8080/health

    The stack takes about 20 seconds to come up, so wait and run the command again if it fails at first. The answer is JSON with status set to ok and a version that names the commit you are running.

  5. Open http://localhost:8080 and sign in with the email and password from .env.

The Codex sign-in page with an email field, a password field and a Sign in button.The Codex sign-in page with an email field, a password field and a Sign in button.

Codex has no sign-up. The first start creates your admin from the two CODEX_ADMIN_ values, and you add everyone else from User management.

After you sign in, Codex opens the Library. A fresh install has no books, so your Library is empty. The picture below shows demo content.

The Library of the demo content, with the Create Novel button at the top and the Working Coasts series below it.The Library of the demo content, with the Create Novel button at the top and the Working Coasts series below it.

You only need the two admin values for the first start. When you have signed in, remove them.

  1. Delete the CODEX_ADMIN_EMAIL and CODEX_ADMIN_PASSWORD lines from the codex service in docker-compose.yml. Do this first. Compose stops with “Set CODEX_ADMIN_EMAIL in .env” if the file still names the variables and they are empty in .env.
  2. Delete the same two lines from .env.
  3. Run docker compose up -d again. Compose recreates the app container without them.

Your admin stays. These variables never change a user who already has a password. After the first start, editing them in .env does not change your password.

Codex gives one answer to every failed sign-in, whatever the cause.

The sign-in page showing the message: Incorrect email or password, or the account is locked for now.The sign-in page showing the message: Incorrect email or password, or the account is locked for now.

The message is “Incorrect email or password, or the account is locked for now.” You see the same message before the first admin exists. With this Compose file that happens if you removed the two admin lines before the first start, because no admin was created. Put the lines back in the Compose file, set both values in .env, and run docker compose up -d again. Once an admin has a password, .env no longer sets it.

Ten wrong passwords in a row lock the account for 15 minutes.

Download docker-compose.yml and .env.example with the commands in step 1. The two files below are the same ones, so what you read matches what you download.

docker-compose.yml
# Codex quick start. Run it with: docker compose up -d
# Copy .env.example to .env and set the three required values first.
services:
codex:
image: ${CODEX_IMAGE:-ghcr.io/codexsuite/codex:latest}
restart: unless-stopped
ports:
- "8080:8080"
depends_on:
postgres:
condition: service_healthy
environment:
- CODEX_DB_CONNECTION=Host=postgres;Port=5432;Database=codex;Username=postgres;Password=${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
# The key ring that encrypts the AI keys users save. Keep this volume, because Codex cannot read those keys without it.
- CODEX_DATA_PROTECTION_DIR=/data/keys
# The app creates this admin on first boot. Remove both lines after you have signed in.
- CODEX_ADMIN_EMAIL=${CODEX_ADMIN_EMAIL:?Set CODEX_ADMIN_EMAIL in .env}
- CODEX_ADMIN_PASSWORD=${CODEX_ADMIN_PASSWORD:?Set CODEX_ADMIN_PASSWORD in .env}
# The app keeps uploaded files, renditions and exports here. The worker shares this volume.
- CODEX_BLOB_ROOT=/data/blobs
volumes:
- codex-blobs:/data/blobs
- codex-keys:/data/keys
worker:
image: ${CODEX_WORKER_IMAGE:-ghcr.io/codexsuite/codex-worker:latest}
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
- CODEX_DB_CONNECTION=Host=postgres;Port=5432;Database=codex;Username=postgres;Password=${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
- CODEX_BLOB_ROOT=/data/blobs
- CODEX_DATA_PROTECTION_DIR=/data/keys
# The web service applies the database migrations. The worker only claims jobs.
- CODEX_DB_MIGRATE=false
# Claims render and export jobs and skips the services that only the web process runs.
- CODEX_ROLE=worker
- CODEX_EVENTS_LISTEN=false
volumes:
- codex-blobs:/data/blobs
- codex-keys:/data/keys
postgres:
image: postgres:18
restart: unless-stopped
command: ["postgres", "-c", "timezone=UTC", "-c", "log_timezone=UTC"]
environment:
- TZ=UTC
- POSTGRES_DB=codex
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
ports:
# This binds to loopback, so other machines cannot reach the database.
- "127.0.0.1:5432:5432"
volumes:
# PostgreSQL 18 images keep the cluster under /var/lib/postgresql.
- codex-pgdata:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d codex"]
interval: 5s
timeout: 5s
retries: 10
volumes:
codex-pgdata:
codex-blobs:
codex-keys:
.env
# Copy this file to .env and fill in the three values. Keep .env out of version control.
# The database password. Use letters and digits only, because it goes into a connection string.
POSTGRES_PASSWORD=
# The app creates this admin on first boot. The password needs at least 10 characters.
CODEX_ADMIN_EMAIL=
CODEX_ADMIN_PASSWORD=
# Optional. To pin the images for production, set these to a commit tag.
# CODEX_IMAGE=ghcr.io/codexsuite/codex:latest
# CODEX_WORKER_IMAGE=ghcr.io/codexsuite/codex-worker:latest

The Compose file reads the image names from CODEX_IMAGE and CODEX_WORKER_IMAGE and defaults both to latest. The images have only the latest tag and one tag per commit, so a production install pins a commit tag. See Install for production.

The app listens on port 8080 over plain HTTP on every network interface. Postgres listens on 127.0.0.1 only.