Server can't find config file

I’m using Nakama 3.1.2 and deploying to the hosted service NodeChef using a Dockerfile (I don’t think they support Docker Compose).

My Dockerfile is a barely modified copy of nakama/Dockerfile at master · heroiclabs/nakama · GitHub

I’m following Docker quickstart - Nakama server but I can’t run docker commands directly, since I don’t have access to the remotely hosted machine.

The problem is I can’t figure out the relationship between files in my project folder and those on the server. No matter what file paths I use, the server can’t find the nakama-config.yml file.

I also saw this thread (and others) Server Configuration - #2 by novabyte and added VOLUME .:/nakama/data and then tried the variant VOLUME ["/nakama/data"], but it had no effect.

The config file is at the root of my project folder, alongside the Dockerfile.

“level”: “fatal”,
“ts”: “2021-03-06T20:14:15.114Z”,
“caller”: “server/config.go:77”,
“msg”: “Could not read config file”,
“path”: “/nakama/data/nakama-config.yml”,
“error”: “open /nakama/data/nakama-config.yml: no such file or directory”

I first had this problem with the server not finding the runtime js_entrypoint file, which is when I decided to try using the config file, and now here I am. :sob:

My legendary persistence has paid off!

From looking at other Dockerfiles in the repo, I discovered that the JS files needed were not being copied to the image in the original Dockerfile I used to base this on. No wonder it was looking everywhere and not finding anything!

:point_right: COPY ./build/*.js /nakama/data/modules/build/

Now my runtime code is printing “Hello World!” in the server log output.

The issue was the same for the config file.

:point_right: COPY ./nakama-config.yml /nakama/data/

And now I see the config file was loaded successfully, too.

1 Like

:+1: for legendary persistence.


Sorry to bump this thread, as we are also facing same issue. We are stuck at this section. Kindly hlep us to resolve this issue as the resolved answer says > COPY ./build/*.js /nakama/data/modules/build/ we unable to get this done.

Hey @chiru, what exactly is your issue? Where is your config.yaml located in your project and where are you attempting to mount it in your Dockerfile?

When we followed tutorial, we are stuck at setting configuration, every thing done as in tutorial and we are using windows OS.
error:open /nakama/data/my-config.yml: no such file or directory

Few things to point out:

  1. As per tutorial, for windows user, volume location to be set as /c/Users/<username>/projects/docker:/nakama/data
    But this doesnt set exact location of project on desktop. So we changed to

  2. On configuration section, doc says to create a data folder inside project and set in volume as
    - ./data:/nakama/data
    So since ours is windows, we gave the full path like below.
    - /Users/<useranme>/Desktop/nakama/data:/nakama/data
    and added below line in entry point of nakama
    /nakama/nakama --config /nakama/data/my-config.yml &&

With this setup with Docker 3.3.0, we got this error:
error: /tmp/path/to/logfile.log : no such file or directory
So we have updated to Docker 3.6.0, we got issue like EOF from github some thing like
docker manifests EOF
So we have installed Docker 3.5.2 and we ran into this issue.

After doing some research and from this post, figured whats actually data path for volume and its corresponding usage. Now our config file is read but still facing issue with path for logger in config file.
my_config.yml is

name: nakama-node-1
data_dir: "./data/"

    stdout: false
    level: "warn"
    file: "/tmp/path/to/logfile.log"

and console prints
error: /tmp/path/to/logfile.log : no such file or directory

also if we remove this logger section, then we ended up in another issue like
{"level":"fatal","ts":"2021-08-24T09:03:43.438Z","caller":"main.go:262","msg":"Error pinging database","error":"dial tcp connect: connection refused"}

@chiru Remember that any paths you put into the config file are relative to the container, not the host system. So if you want to write to a logfile rather than stdout map a volume from the host system to your container, and specify the logger.file option value using that mounted volume.

This is a separate issue. It only surfaces if you remove the logger section because otherwise due to your invalid logger configuration the server doesn’t get as far as connecting to the database. The error indicates the server can’t reach the database as you’ve configured it, or using the default database connection configuration if you haven’t set your own.

The fix here depends on how you’re running your database, but have a look at the database configuration documentation for the values you’re expected to set. The most important is database.address.

@zyro But when we remove the config entry from entrypoint i.e.,
/nakama/nakama --config /nakama/data/my-config.yml &&
Now app works fine and connecting the database.

My whole compose scripts are:

version: '3'
    image: cockroachdb/cockroach:latest-v20.2
    command: start-single-node --insecure --store=attrs=ssd,path=/var/lib/cockroach/
    restart: "no"
      - data:/var/lib/cockroach
      - "8080"
      - "26257"
      - "26257:26257"
      - "8080:8080"
    image: heroiclabs/nakama:3.2.1
      - "/bin/sh"
      - "-ecx"
      - >
        /nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
        /nakama/nakama --config /nakama/data/my-config.yml &&
        exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100 --runtime.path "/nakama/data/modules/"
    restart: "no"
      - "cockroachdb:db"
      - cockroachdb
      - prometheus
      - /c/Users/Chiranjeevi/Desktop/nakama/data:/nakama/data
      - "7349"
      - "7350"
      - "7351"
      - "9100"
      - "7349:7349"
      - "7350:7350"
      - "7351:7351"
      test: ["CMD", "curl", "-f", "http://localhost:7350/"]
      interval: 10s
      timeout: 5s
      retries: 5
    image: prom/prometheus
    entrypoint: /bin/sh -c
    command: |
      'sh -s <<EOF
        cat > ./prometheus.yml <<EON
        scrape_interval:     15s
        evaluation_interval: 15s
        - job_name: prometheus
          - targets: ['localhost:9090']
        - job_name: nakama
          metrics_path: /
          - targets: ['nakama:9100']
      prometheus --config.file=./prometheus.yml
      - '9090:9090'

and my-config.yml

name: nakama-node-1
data_dir: "./data/"

    stdout: false
    level: "warn"
    file: "/tmp/path/to/logfile.log"

    port: 7351
    username: "my_user"
    password: "my_password"

Your docker-compose.yml file looks invalid. Specifically this portion of the nakama container’s entrypoint:

/nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
/nakama/nakama --config /nakama/data/my-config.yml &&
exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100 --runtime.path "/nakama/data/modules/"

It looks like you’re trying to start nakama twice after the migration step. Unless that is 100% what you meant to do, this is a mistake.

What you probably want is this:

/nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
exec /nakama/nakama --config /nakama/data/my-config.yml --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100 --runtime.path "/nakama/data/modules/"

@zyro still is shows the same error.

Also in docs, its not clear at this section. Where they requested to add certain line as new line itself.

@chiru The documentation does not indicate you should add a new line. You can see the original file a little earlier on the same page - there are already 2 lines in the entrypoint. The section you then pointed out still only has 2 lines.

Either way the error is the same because you did not change the log file location. Set a valid log file location, in a mounted volume the nakama docker container can write to, and it will work.


@zyro thanks it works now as ive given parent folder itself.