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 guide, Docker only changes where the file lives and how it’s passed to Nakama.
Step 1: Mount a host directory as a Docker volume #
- Open your
docker-compose.ymlfile in your preferred text editor. - Edit the
nakama:volumes:entry to specify your volume. For example, to map a local./datadirectory to/nakama/datainside the container:
| |
This maps the local ./data directory to the /nakama/data path inside the Nakama container.
- Save the file and restart your Docker services:
| |
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
| |
CockroachDB example #
my-config.yml
| |
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:
| |
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:
| |
