# Docker Override (https://www.librechat.ai/docs/configuration/docker_override)

A Docker Compose override file lets you change the default configuration in `docker-compose.yml` without editing or duplicating it. Override files are mainly for local customizations. When you run `docker compose up`, Compose merges `docker-compose.yml` with `docker-compose.override.yml` automatically.

<Callout type="info" title="More examples">
See `docker-compose.override.yml.example` in the repository for a fuller set of override snippets you can copy from.
</Callout>

## Configure the Override

<Steps>
<Step>

**Create the override file.** If you don't already have one, copy the example. Docker Compose picks it up automatically when you run `docker compose` commands.

```bash filename="terminal"
cp docker-compose.override.yml.example docker-compose.override.yml
```

</Step>
<Step>

**Edit the override file.** Open `docker-compose.override.yml` in your editor, then uncomment and customize the sections you need.

<Callout type="warning" title="One entry per service">
Each service name (`api`, `mongodb`, `meilisearch`, ...) can appear only once. To override multiple settings on a single service, combine them under that one entry.
</Callout>

</Step>
<Step>

**Apply the changes.** Run Docker Compose as usual. It merges `docker-compose.yml` and `docker-compose.override.yml` for you.

```bash filename="terminal"
docker compose up -d
```

</Step>
<Step>

**Verify the changes.** List the running containers and their properties, such as ports, to confirm your overrides took effect.

```bash filename="terminal"
docker ps
```

</Step>
</Steps>

## Examples

To mount your `librechat.yaml` config file so Docker can use it for [Custom Endpoints & Configuration](/docs/configuration/librechat_yaml):

```yaml filename="docker-compose.override.yml"
services:
  api:
    volumes:
      - ./librechat.yaml:/app/librechat.yaml
```

To build the `api` image locally, mount the config file, and use an older MongoDB that doesn't require AVX support:

```yaml filename="docker-compose.override.yml"
services:
  api:
    volumes:
      - ./librechat.yaml:/app/librechat.yaml
    image: librechat
    build:
      context: .
      target: node

  mongodb:
    image: mongo:4.4.18
```

<Callout type="warning" title="Watch exposed ports">
Exposing MongoDB or Meilisearch ports to the public can leave your data vulnerable. Avoid default ports for production or sensitive environments.
</Callout>

## Using `deploy-compose.yml`

With a non-default Compose file such as `deploy-compose.yml`, the override is not loaded automatically. Pass both files explicitly with `-f` (or `--file`); settings in later files override or add to earlier ones.

The override file can have any name, though you may already have `docker-compose.override.yml` in place. Run commands like so:

```bash filename="terminal"
docker compose -f deploy-compose.yml -f docker-compose.override.yml pull
docker compose -f deploy-compose.yml -f docker-compose.override.yml up
```

## Reference

- **Order of precedence:** values in the override file take precedence over the same values in `docker-compose.yml`.
- **Security:** when customizing ports and exposing services publicly, be conscious of the security implications and avoid defaults for production.

For more detail, see the official Docker documentation:

- [Understanding multiple Compose files](https://docs.docker.com/compose/how-tos/multiple-compose-files/extends/)
- [Merge Compose files](https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/)
- [Specifying multiple Compose files](https://docs.docker.com/compose/reference/#specifying-multiple-compose-files)
