# Docker Compose

Get LangWatch running locally in minutes with Docker Compose

> Page: https://langwatch.ai/docs/self-hosting/deployment/docker-compose
> Source: https://github.com/langwatch/langwatch/blob/main/docs/self-hosting/deployment/docker-compose.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

Docker Compose is the quickest way to try LangWatch locally. It runs the full stack in containers on your machine.

## Prerequisites

- [Docker](https://docs.docker.com/get-docker/) with Docker Compose v2
- 4 CPU cores, 8 GB RAM, 20 GB disk

## Quick Start

```bash
# Clone the repository
git clone https://github.com/langwatch/langwatch.git
cd langwatch

# Copy the example environment file, then replace its placeholder secrets (see Configuration)
cp .env.example .env

# Start all services
docker compose -f infra/compose.yml --project-directory . up
```

The compose file lives at `infra/compose.yml` and reads `.env` at the repository root, so run every `docker compose` command from the repository root with `-f infra/compose.yml --project-directory .`. The commands below use that form.

LangWatch is available at **http://localhost:5560**.

> **Tip:** Why port 5560? On a T9 keyboard, 5560 spells "LLM".

## Services

Docker Compose starts the following services:

| Service         | Image                                   | Host port | Description                 |
| --------------- | --------------------------------------- | --------- | --------------------------- |
| `app`           | `langwatch/langwatch:latest`            | 5560      | Main application            |
| `workers`       | `langwatch/langwatch:latest`            | -         | Background job processing   |
| `langwatch_nlp` | `langwatch/langwatch_nlp:latest`        | -         | NLP processing, workflows   |
| `langevals`     | `langwatch/langevals:latest`            | 5562      | Evaluators, guardrails      |
| `postgres`      | `postgres:16`                           | 5432      | Control plane database      |
| `redis`         | `redis:alpine`                          | -         | Job queue, caching          |
| `clickhouse`    | `langwatch/clickhouse-serverless:0.4.0` | 8123      | Trace and analytics storage |

Services with no host port bind no port on the host's interfaces, so they do not answer on `localhost` and are not reachable from another machine. `langwatch_nlp` listens on 5561 inside the Docker network, which is what `LANGWATCH_NLP_SERVICE` points the app and the workers at. A process on the Docker host itself can still reach a container directly on its own network address, so treat this as removing an exposed entry point, not as a network boundary.

## Configuration

Edit `.env` to customize your deployment. Key variables:

```bash
# Required: replace the placeholders that .env.example ships
# Signs sessions. Generate with: openssl rand -base64 32
NEXTAUTH_SECRET=your-session-secret
# Encrypts stored credentials and peppers API key hashes.
# Must be exactly 64 hex characters. Generate with: openssl rand -hex 32
CREDENTIALS_SECRET=your-64-hex-character-key
# Password of ClickHouse's default user. Keep it URL-safe. Generate with:
# openssl rand -hex 24. Unset, compose falls back to the published `langwatch`
# (deprecated, warned at every boot, removed in the next major release).
CLICKHOUSE_PASSWORD=your-clickhouse-password

# Optional: shared credential the app authenticates to the NLP service with.
# Every container in the stack reads this file, so one value covers both sides.
# Generate with: openssl rand -hex 32
LANGWATCH_NLP_INTERNAL_SECRET=

# Optional: an Enterprise license, either an activation code
# (LW-XXXX-XXXX-XXXX-XXXX, needs outbound HTTPS to connect.langwatch.ai)
# or a signed license key (works offline)
LANGWATCH_LICENSE_KEY=
```

See [Editions and licensing](https://langwatch.ai/docs/self-hosting/licensing#two-forms-of-license) for how each form is applied at startup. Keep `CREDENTIALS_SECRET` stable once LangWatch holds data: changing it makes stored credentials unreadable, and also invalidates API keys unless `API_KEY_PEPPER` is set. To replace it, see [Rotating the credentials secret](https://langwatch.ai/docs/self-hosting/security#rotating-the-credentials-secret).

Dashboards, the SQL workbench and Instant Evals read through a restricted ClickHouse user and a PostgreSQL reader role. The upgrade creates both. Their passwords are derived from `CREDENTIALS_SECRET` (or `API_KEY_PEPPER` when you set it), so you don't set anything for them. To pick your own, set both `LWQL_CLICKHOUSE_PASSWORD` and `LWQL_POSTGRES_READER_PASSWORD`.

Creating them needs a ClickHouse user that can create users, roles and named collections, `custom_` in the server's `custom_settings_prefixes`, and a PostgreSQL user with `CREATEROLE`. The bundled ClickHouse has all of it. If yours doesn't, as on some managed ClickHouse services, the upgrade logs a warning naming what is missing and carries on, and those three features stay off until you add it. With your own passwords set, a missing grant fails the upgrade instead.

See [Environment Variables](https://langwatch.ai/docs/self-hosting/configuration/environment-variables) for the full reference.

## Common Operations

### Start in the background

```bash
docker compose -f infra/compose.yml --project-directory . up -d
```

### View logs

```bash
# All services
docker compose -f infra/compose.yml --project-directory . logs -f

# Specific service
docker compose -f infra/compose.yml --project-directory . logs -f app
```

### Stop services

```bash
docker compose -f infra/compose.yml --project-directory . down
```

### Update to latest version

```bash
docker compose -f infra/compose.yml --project-directory . pull
docker compose -f infra/compose.yml --project-directory . up -d
```

The workers run `pnpm task upgrade` on the new image when they start, and the app does not report ready until it completes. On a current installation it applies no step. If it fails, read `docker compose logs workers`; the exit code is explained in the [Upgrade Guide](https://langwatch.ai/docs/self-hosting/upgrade#exit-codes-and-what-to-do).

### Reset data

```bash
docker compose -f infra/compose.yml --project-directory . down -v  # Removes volumes (all data)
docker compose -f infra/compose.yml --project-directory . up
```

## Customization

### Disable optional services

If you don't need NLP or evaluators, comment them out in `infra/compose.yml`:

```yaml
services:
  # langwatch_nlp:
  #   ...
  # langevals:
  #   ...
```

Remove the corresponding upstream URLs from the app environment to avoid connection errors.

### Connect to external databases

Replace the `postgres` and `redis` services with connection strings to your existing instances:

```yaml
services:
  app:
    environment:
      DATABASE_URL: postgresql://user:password@your-postgres:5432/langwatch
      REDIS_URL: redis://:password@your-redis:6379
    depends_on: [] # Remove postgres and redis dependencies
```

### Connect to external ClickHouse

Replace the `clickhouse` service with a connection string to your existing instance:

```yaml
services:
  app:
    environment:
      CLICKHOUSE_URL: http://user:password@your-clickhouse:8123/langwatch
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
      # Remove clickhouse from depends_on
```

## Limitations

Docker Compose is suitable for evaluation and small teams but lacks:

- **High availability**: single instance of each service
- **Horizontal scaling**: cannot scale workers independently
- **Automated backups**: no built-in backup scheduling
- **TLS**: no built-in HTTPS (use a reverse proxy like nginx or Caddy)

For production, migrate to the [Kubernetes Helm chart](https://langwatch.ai/docs/self-hosting/deployment/kubernetes-helm).

## Next Steps

- [First run](https://langwatch.ai/docs/self-hosting/first-run): Create the first account, add the license and connect your identity provider
- [Docker Images](https://langwatch.ai/docs/self-hosting/deployment/docker-images): Learn about each container image
- [Kubernetes (Helm)](https://langwatch.ai/docs/self-hosting/deployment/kubernetes-helm): Production deployment
- [Environment Variables](https://langwatch.ai/docs/self-hosting/configuration/environment-variables): Full configuration reference

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
