# Install with Docker Compose

> Install the XTM stack for production on one host with the official Docker Compose deployment, with secrets, public URLs, persistent data and pinned versions.

- URL: https://filigran.io/docs/lts/7.260309-lts/deploy/install/docker-compose/
- Products (the whole suite): XTM One 1.261119.1, OpenCTI 7.260309.0-lts.8, OpenAEV 3.261118.0, OpenCRQ 0.261123.0, XTM Composer 3.261121.0
- OpenCTI line: 7.260309 LTS · 7.260309.0-lts.8
- For: platform engineers
- Type: How-to guide

This page installs the XTM stack for production on one host with the official Docker deployment, [FiligranHQ/xtm-docker](https://github.com/FiligranHQ/xtm-docker). At the end, the whole stack, XTM One, OpenCTI, OpenAEV, OpenCRQ, XTM Composer and their default integrations, runs with strong secrets, the public addresses of your users, data kept in Docker volumes and versions that change only when you decide. Every install of the XTM platform runs all its modules together: there is no install of one module on its own. To try the platform first, follow [Run the XTM platform locally](https://filigran.io/docs/lts/7.260309-lts/deploy/quick-start/): it uses the same files with fewer steps.

**Diagram: You prepare the host, write .env and docker-compose.override.yml, start the stack, whose data stays in Docker volumes, and publish it through a reverse proxy on local ports**

- Prepare: The host (vm.max_map_count, Docker at boot, git clone)
- Configure: .env (Secrets, admins, mail, public URLs), docker-compose.override.yml (Local ports, pinned versions, workers)
- Start: The whole XTM platform (docker compose pull, then up -d)
- Data: Docker volumes (xtm_esdata, xtm_pgsqlshareddata and others)
- Publish: Reverse proxy (HTTPS for your users)

Connections:

- The host → .env: secrets script
- .env → The whole XTM platform: settings and secrets
- docker-compose.override.yml → The whole XTM platform: merged at each command
- The whole XTM platform → Docker volumes: keeps its data
- Reverse proxy → The whole XTM platform: 127.0.0.1:8080 to 8090

> **Note: The Compose files of the OpenCTI repository**
>
> [OpenCTI-Platform/docker](https://github.com/OpenCTI-Platform/docker) is a second Compose deployment, for OpenCTI with XTM One and XTM Composer, without OpenAEV. It has an OpenSearch variant, `docker-compose.opensearch.yml`. Its `.env.sample` names the OpenCTI and XTM One settings as xtm-docker does, but its services differ (XTM One has its own PostgreSQL, `pgsql-xtm-one`) and so does its mail setting (`SMTP_HOSTNAME`): the commands of this page do not apply to it as they are. This page follows xtm-docker.

## Before you start {#before-you-start}

- A Linux host with Docker Engine 20.10 or later and Docker Compose 2.24.4 or later: `docker compose version` prints it. An earlier v2 stops on the `include` list of `docker-compose.yml` (2.20) or on the `!override` tags of this page (2.24.4). To install them, follow the [Docker Engine installation guide](https://docs.docker.com/engine/install/).
- 16 GB of RAM at least, 32 GB recommended for production, and 50 GB of free disk. [Sizing](https://filigran.io/docs/lts/7.260309-lts/deploy/plan/sizing/) says how much each module needs.
- An Intel or AMD (amd64) processor: XTM One is published for amd64 only.
- Python 3, to pin the image versions.
- For each platform users reach, the host name they will type, such as `opencti.example.com`, and a reverse proxy that serves it over HTTPS: see [Publish the platforms over HTTPS](https://filigran.io/docs/lts/7.260309-lts/deploy/install/reverse-proxy/).

## Prepare the host {#prepare-the-host}

1. Raise the memory map limit that Elasticsearch needs, now and after every restart.

   ```bash
   echo 'vm.max_map_count=262144' | sudo tee /etc/sysctl.d/99-xtm-elasticsearch.conf
   sudo sysctl --system
   ```

   **Check that it worked**

   ```bash
   sysctl vm.max_map_count
   ```
   It prints `vm.max_map_count = 262144`.

2. Make Docker start with the host. Every service of the stack has `restart: always`, except `xtm-one-db-init`, which runs once at each start, so the stack comes back when Docker does.

   ```bash
   sudo systemctl enable --now docker
   ```

3. Get the deployment.

   ```bash
   git clone https://github.com/FiligranHQ/xtm-docker.git
   cd xtm-docker
   ```

## Configure the stack {#configure-the-stack}

`docker-compose.yml` includes one file per shared service, under `infra/`, and one file per module, under `modules/`: `xtm-one.yml`, `opencti.yml`, `openaev.yml`, `opencrq.yml` and `xtm-composer.yml`. Every service they list starts, and XTM Composer manages both OpenCTI and OpenAEV.

All the configuration is in `.env`, except the ports, the image versions and the number of workers, which these Compose files set. Change those in `docker-compose.override.yml`, never in the files of xtm-docker: see [Change the stack without editing docker-compose.yml](#change-the-stack-without-editing-docker-compose-yml).

1. Create `.env` with fresh secrets.

   ```bash
   docker compose -f init.yml run --rm init
   ```

   A temporary container copies `.env.sample` and gives every password, key and token a random value: a UUID for the admin tokens and health check keys, a 32-byte base64 key for `OPENCTI_ENCRYPTION_KEY`, and a random string for the others. It names the users of PostgreSQL and RabbitMQ, sends mail to `localhost` until step 3, makes `.env` readable by its owner alone, and never overwrites an existing `.env`. It prints the admin password of each platform.

   `.env` now holds every secret of the stack, including the encryption keys of OpenCTI and OpenAEV. Keep a copy in your secret store: you need the same values to restore the stack.

2. Set the admin accounts. Give `OPENCTI_ADMIN_EMAIL`, `OPENAEV_ADMIN_EMAIL` and `XTM_ONE_ADMIN_EMAIL` the address of your administrator. `XTM_ONE_ADMIN_EMAIL` must be the admin email of the platforms XTM One connects to: XTM One finds the user by this address.

   ```bash
   ADMIN=admin@example.com
   sed -i.bak -E "s/^(OPENCTI|OPENAEV|XTM_ONE)_ADMIN_EMAIL=.*/\1_ADMIN_EMAIL=${ADMIN}/" .env
   ```

3. Set the mail server. Replace the `SMTP_*` values of `.env` with those of your relay: `SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, and `SMTP_AUTH`, `SMTP_SSL_ENABLE`, `SMTP_STARTTLS_ENABLE` set to `true` or `false`. If OpenAEV does not read a mailbox, set `OPENAEV_MAIL_IMAP_ENABLED=false` and leave the `IMAP_*` values.

   > **Note**
   >
   > OpenAEV uses every `SMTP_*` value. OpenCTI uses only `SMTP_HOST`, on port 25 without authentication, as `docker-compose.yml` sets it. To send OpenCTI mail through an authenticated relay, see [Configure the shared services](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/shared-services/).

4. Fit Elasticsearch to the host. `ELASTIC_MEMORY_SIZE` is the Java heap of Elasticsearch, `4G` in `.env.sample`.

   | RAM of the host | `ELASTIC_MEMORY_SIZE` |
   | --- | --- |
   | 16 GB | `2G` |
   | 32 GB | `4G` |
   | 64 GB or more | `8G` |

   ```bash
   sed -i.bak 's/^ELASTIC_MEMORY_SIZE=.*/ELASTIC_MEMORY_SIZE=8G/' .env
   ```

5. Set the public URLs. Each platform builds its URL from three variables of `.env`: the scheme, the host and the port that users type. For platforms served over HTTPS by a reverse proxy on port 443, set:

   ```bash
   OPENCTI_EXTERNAL_SCHEME=https
   OPENCTI_HOST=opencti.example.com
   OPENCTI_PORT=443

   OPENAEV_EXTERNAL_SCHEME=https
   OPENAEV_HOST=openaev.example.com
   OPENAEV_PORT=443

   XTM_ONE_EXTERNAL_SCHEME=https
   XTM_ONE_HOST=xtm-one.example.com
   XTM_ONE_PORT=443

   OPENCRQ_EXTERNAL_SCHEME=https
   OPENCRQ_HOST=opencrq.example.com
   OPENCRQ_PORT=443
   ```

   These URLs are also the identity each module signs its requests to the others with. Inside the stack, the containers reach each other on their service names (`http://opencti:8080`, `http://openaev:8080`, `http://xtm-one:4000`, `http://opencrq:3002`), so the public host names do not need to resolve inside Docker.

6. Publish the platforms on local ports for the reverse proxy. `docker-compose.yml` publishes OpenCTI on `OPENCTI_PORT` and XTM One on `XTM_ONE_PORT`, so with the values above Docker would take port 443 that the proxy needs. It also publishes Elasticsearch and Redis, which run without authentication, on every interface. This command creates `docker-compose.override.yml`, which binds every published port to the host itself, with OpenCTI on 8080, OpenAEV on 8081 and XTM One on 8090. `ports: !override` replaces the ports of `docker-compose.yml` instead of adding to them:

   ```bash
   cat > docker-compose.override.yml <<'EOF'
   services:
     opencti:
       ports: !override
         - "127.0.0.1:8080:8080"
     openaev:
       ports: !override
         - "127.0.0.1:8081:8080"
     xtm-one:
       ports: !override
         - "127.0.0.1:8090:4000"
     opencrq:
       ports: !override
         - "127.0.0.1:8082:3002"
     elasticsearch:
       ports: !override
         - "127.0.0.1:9200:9200"
     redis:
       ports: !override
         - "127.0.0.1:6379:6379"
     minio:
       ports: !override
         - "127.0.0.1:9000:9000"
     rabbitmq:
       ports: !override
         - "127.0.0.1:5672:5672"
         - "127.0.0.1:15672:15672"
   EOF
   ```

   > **Note**
   >
   > An integration that runs on another host, outside XTM Composer, needs to reach some of these services. See [Run an integration without XTM Composer](https://filigran.io/docs/lts/7.260309-lts/deploy/integrations/manual/) before you close them.

7. Pin the versions. `docker-compose.yml` uses the `latest` tag, so every `docker compose pull` could upgrade a platform. Write the releases you install in `docker-compose.override.yml` with the commands of [Pin the image versions](#pin-the-image-versions), here the current ones: `OPENCTI_VERSION=7.261119.0`, `OPENAEV_VERSION=3.261118.0`, `XTM_ONE_VERSION=1.261119.1` and `OPENCRQ_VERSION=0.261123.0`.

   The OpenCTI connectors and the OpenAEV collectors and injectors follow the version of their platform. xtm-docker pins RustFS, the S3 storage, to `1.0.4`. XTM Composer, the `alpine/openssl` key generator and the AWS command line interface of `opencrq-bucket-init` keep `latest`. Check which versions work together in [Compatibility between modules](https://filigran.io/docs/lts/7.260309-lts/deploy/upgrade/compatibility/).

8. Size the OpenCTI workers. The worker writes the data that connectors send to OpenCTI; `modules/opencti.yml` starts 3 of them. For more throughput, set `replicas` of the `worker` service in `docker-compose.override.yml`: add the `worker` lines below under the `services:` key of the file, above the `# Pinned versions` line.

   ```yaml
   services:
     worker:
       deploy:
         replicas: 4
   ```

   [Scale: workers, platforms and clusters](https://filigran.io/docs/lts/7.260309-lts/deploy/operate/scale/) explains when to add workers.

   **Check that it worked**

   ```bash
   docker compose config --quiet && echo "configuration OK"
   docker compose config --services
   ```
   It prints `configuration OK`, then the 32 services of the stack: XTM One with its worker and `xtm-one-db-init`, OpenCTI with its worker and ten connectors, OpenAEV with four collectors and two injectors, OpenCRQ with `opencrq-db-init` and `opencrq-bucket-init`, XTM Composer with `rsa-key-generator`, and the five shared services. `opensandbox`, which runs the code of XTM One's agents, starts only with its profile: see [Run code in OpenSandbox](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/xtm-one/#run-code-in-opensandbox).

## Start the stack {#start-the-stack}

1. Download the images, then start the stack.

   ```bash
   docker compose pull
   docker compose up -d
   ```

   The first start creates the databases and the indices: allow a few minutes.

2. Wait until the platforms are healthy.

   ```bash
   docker compose ps --format '{{.Service}} {{.Health}}' | grep -E '^(opencti|openaev|xtm-one|opencrq) '
   ```

   **Check that it worked**

   `opencti`, `openaev`, `xtm-one` and `opencrq` say `healthy`. On the host, OpenCTI, OpenAEV and XTM One answer their health check on their local port:

   ```bash
   set -a; . ./.env; set +a
   curl -fsS "http://127.0.0.1:8080/health?health_access_key=$OPENCTI_HEALTHCHECK_ACCESS_KEY" >/dev/null && echo "OpenCTI OK"
   curl -fsS "http://127.0.0.1:8081/api/health?health_access_key=$OPENAEV_HEALTHCHECK_KEY" >/dev/null && echo "OpenAEV OK"
   curl -fsS "http://127.0.0.1:8090/api/health" >/dev/null && echo "XTM One OK"
   ```

3. Put the reverse proxy in front of the platforms, as [Publish the platforms over HTTPS](https://filigran.io/docs/lts/7.260309-lts/deploy/install/reverse-proxy/) describes, then sign in at each public URL with the admin email and password of `.env`. OpenCRQ has no password of its own: XTM One's administrator signs in to it through XTM One and lands in its first tenant, `Default`, which OpenCRQ creates at its first start. Then [finish the setup of each module](#finish-the-setup-of-each-module).

## Finish the setup of each module {#finish-the-setup-of-each-module}

The stack runs every module from its first start. Each one has a few steps left before people use it:

| Module | What is left | Where |
| --- | --- | --- |
| OpenCTI and OpenAEV | Sign in with the admin email and password of `.env`, and keep a break-glass account before you turn on single sign-on | [Sign in the first time and keep an emergency account](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/first-access/) |
| XTM One | Trust the reverse proxy, let it stream the chat, connect a language model and give it its edition | [Finish the setup of XTM One](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/xtm-one/#finish-the-setup-after-the-install) |
| OpenCRQ | Check its public URL and its registration with XTM One, then sign in to its first tenant through XTM One | [Finish the setup of OpenCRQ](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/opencrq/#finish-the-setup-after-the-install) |
| Every module | Check that the modules registered with XTM One and reach each other | [Connect the modules to each other](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/connect-modules/) |

## Change the stack without editing docker-compose.yml {#change-the-stack-without-editing-docker-compose-yml}

`docker-compose.yml` belongs to the xtm-docker repository: change it, and every `git pull` conflicts with your change. Put every local change in `docker-compose.override.yml`, next to it, instead. Docker Compose reads that file after `docker-compose.yml` on every command and merges the two. `.env` keeps the values xtm-docker reads from it; the override file holds the rest: environment variables, mounts, ports, image versions and the number of workers.

This example raises the log level of OpenCTI, mounts a folder of certificates in it, publishes it on the host only, and starts four workers:

```yaml
services:
  opencti:
    environment:
      - APP__APP_LOGS__LOGS_LEVEL=info
    volumes:
      - ./certs:/opt/opencti/certs:ro
    ports: !override
      - "127.0.0.1:8080:8080"
  worker:
    deploy:
      replicas: 4
```

Docker Compose merges each key in its own way:

| Key | What the override file does |
| --- | --- |
| `environment` | Adds the variable, or replaces the value of the variable of the same name |
| `volumes` | Adds the mount, or replaces the mount on the same path in the container |
| `ports` | Adds to the ports of `docker-compose.yml`. `ports: !override` followed by a list replaces them, `ports: !reset []` removes them |
| `depends_on` | Adds the dependency. `<service>: !reset null` under it removes one |
| `profiles` | Adds to the profiles. `profiles: !override ["disabled"]` keeps the service from starting |
| `image`, `deploy.replicas` and the other single values | Replaces the value |
| A service that `docker-compose.yml` does not have | Adds it |

`!reset` needs Docker Compose 2.24 or later, and `!override` 2.24.4 or later. Above the pinned versions, write one `services:` key, and each service once under it: when a page gives lines for a service your file already has, add them under that service. Docker Compose refuses a file that repeats a key, with `mapping key "opencti" already defined`.

**Check that it worked**

```bash
docker compose config --quiet && echo "configuration OK"
docker compose config | grep -E 'LOGS_LEVEL|host_ip|replicas'
```
With the example as `docker-compose.override.yml`, it prints `configuration OK`, then `APP__APP_LOGS__LOGS_LEVEL: info`, `host_ip: 127.0.0.1` and `replicas: 4`: the merged configuration has the values of the override file.

Apply the change with `docker compose up -d`: Docker Compose recreates the containers whose configuration changed. After a `git pull`, run `docker compose config --quiet` again, and compare what you replaced with `!override` to the new `docker-compose.yml`.

### Pin the image versions {#pin-the-image-versions}

These commands pin the OpenCTI, OpenAEV, XTM One and OpenCRQ images of the stack. They write the image of each service, with the versions you set, at the end of `docker-compose.override.yml`. Run them again to change the versions: they replace that part of the file.

```bash
OPENCTI_VERSION=7.261119.0
OPENAEV_VERSION=3.261118.0
XTM_ONE_VERSION=1.261119.1
OPENCRQ_VERSION=0.261123.0
touch docker-compose.override.yml
sed -i.bak '/^# Pinned versions/,$d' docker-compose.override.yml
PINNED=$(docker compose config --format json | python3 -c '
import json, sys
tags = dict(zip(["opencti", "openaev", "xtmone", "filigran/opencrq"], sys.argv[1:]))
for name, service in sorted(json.load(sys.stdin)["services"].items()):
    repo = service["image"].rsplit(":", 1)[0]
    key = repo if repo in tags else repo.split("/")[0]
    if key in tags:
        print(f"  {name}:\n    image: {repo}:{tags[key]}")
' "$OPENCTI_VERSION" "$OPENAEV_VERSION" "$XTM_ONE_VERSION" "$OPENCRQ_VERSION")
printf '%s\n' '# Pinned versions: keep this part last, the pinning commands rewrite it' '---' 'services:' "$PINNED" >> docker-compose.override.yml
```

The `---` line starts a second part of the file, which Docker Compose merges like the first. Keep your other changes above the `# Pinned versions` line: the commands delete everything from that line to the end of the file.

**Check that it worked**

```bash
docker compose config --images | grep -E '^(opencti|openaev|xtmone|filigran/opencrq)'
```
Every image ends with the version you set.

## Where the data is {#where-the-data-is}

The data of the stack lives in Docker volumes, named after `COMPOSE_PROJECT_NAME` (`xtm` in `.env.sample`). They survive `docker compose down` and a restart of the host, and only `docker compose down -v` deletes them.

| Volume | Holds |
| --- | --- |
| `xtm_esdata` | Elasticsearch: the knowledge of OpenCTI and the indices of OpenAEV |
| `xtm_pgsqlshareddata` | PostgreSQL: the `openaev`, `opencrq` and `xtm_one` databases |
| `xtm_s3data` | RustFS, the S3 object storage: files of OpenCTI, OpenAEV, OpenCRQ and XTM One |
| `xtm_redisdata` | Redis, used by OpenCTI for its event stream and by XTM One |
| `xtm_amqpdata` | RabbitMQ: the messages waiting for the workers and integrations |
| `xtm_rsakeys` | The private key of XTM Composer |

```bash
docker volume ls --filter label=com.docker.compose.project=xtm
```

Back them up together with `.env`: see [Back up and restore](https://filigran.io/docs/lts/7.260309-lts/deploy/operate/backup/).

## What's next {#what-s-next}

- [Publish the platforms over HTTPS](https://filigran.io/docs/lts/7.260309-lts/deploy/install/reverse-proxy/), to publish the platforms over HTTPS.
- [Configure XTM One](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/xtm-one/) and [Configure OpenCRQ](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/opencrq/), to finish their setup.
- [Connect the modules to each other](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/connect-modules/), to check the links between XTM One, OpenCTI, OpenAEV, OpenCRQ and XTM Composer.
- [Sign in the first time and keep an emergency account](https://filigran.io/docs/lts/7.260309-lts/deploy/configure/first-access/), before you turn on single sign-on.
- [Start the whole stack on an existing deployment](https://filigran.io/docs/lts/7.260309-lts/deploy/install/modules/), for a deployment that ran only some modules.
- [Install offline or with FIPS 140-3](https://filigran.io/docs/lts/7.260309-lts/deploy/install/air-gapped/), for a host without internet access.
