# Docker Configuration

**URL:** https://heroiclabs.com/docs/nakama/getting-started/configuration/docker-configuration/
**Summary:** Learn how to configure Nakama via Docker and a Docker Compose file.
**Keywords:** config, docker, docker
**Categories:** nakama, docker-configuration, configuration

---


# Docker configuration

Use this guide to configure Nakama when running with Docker. Bind a local folder into the container, place a YAML config there, and reference it in `docker-compose.yml` so the server reads it at startup. The config file uses the same YAML schema described in the [Server configuration](../../configuration/) guide, Docker only changes where the file lives and how it’s passed to Nakama.

{{<note "important" "">}}
This guide assumes you've followed the steps in [Install Nakama with Docker Compose](../../install/docker/).
{{</note>}}

## Step 1: Mount a host directory as a Docker volume

1. Open your `docker-compose.yml` file in your preferred text editor.
2. Edit the `nakama:volumes:` entry to specify your volume. For example, to map a local `./data` directory to `/nakama/data` inside the container:

```yaml
volumes:
  - ./data:/nakama/data
```

This maps the local `./data` directory to the `/nakama/data` path inside the Nakama container.

3. Save the file and restart your Docker services:

```sh
docker compose restart
docker compose up
```

## Step 2: Create a Nakama configuration file

Create a custom configuration file, for example `my-config.yml`, and place it in the `/data` folder you mounted.

#### PostgreSQL example

**my-config.yml**

```yaml
name: nakama1
database:
  address:
    - "postgres:localdb@postgres:5432/nakama"
logger:
  level: DEBUG
session:
  token_expiry_sec: 7200
```

#### CockroachDB example

**my-config.yml**

```yaml
name: nakama1
database:
  address:
    - "root@cockroachdb:26257"
logger:
  level: DEBUG
session:
  token_expiry_sec: 7200
metrics:
  prometheus_port: 9100
```

## Step 3: Point Nakama to the config in `docker-compose.yml`

Edit the Nakama service’s `entrypoint` to include the `--config` flag that references the file in `/nakama/data`:

```yaml
nakama:
  entrypoint:
    - "/bin/sh"
    - "-ecx"
    - >
      /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
      /nakama/nakama --config /nakama/data/my-config.yml
```

If using CockroachDB, replace `postgres:localdb@postgres:5432/nakama` with `root@cockroachdb:26257`.

## Step 4: Restart Docker containers

Save the file and restart for the changes to take effect:

```sh
docker compose restart
docker compose up
```
