I am getting error while running docker-composer file

I have a docker-compose file of postgres but getting error at the time of running.
docker-compose file content
version: ‘3’
services:
postgres:
container_name: postgres
image: postgres:9.6-alpine
environment:
- POSTGRES_DB=nakama
- POSTGRES_PASSWORD=localdb
volumes:
- data:/var/lib/postgresql/data
expose:
- “8080”
- “5432”
ports:
- “5432:5432”
- “8080:8080”
nakama:
container_name: nakama
image: heroiclabs/nakama:2.4.1
entrypoint:
- “/bin/sh”
- “-ecx”
- >
/nakama/nakama migrate up --database.address postgres@postgres:5432/nakama &&
exec /nakama/nakama --name nakama1 --database.address postgres@postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 7200
restart: always
links:
- “postgres:db”
depends_on:
- postgres
volumes:
- ./:/nakama/data
expose:
- “7349”
- “7350”
- “7351”
ports:
- “7349:7349”
- “7350:7350”
- “7351:7351”
healthcheck:
test: [“CMD”, “curl”, “-f”, “http://localhost:7350/”]
interval: 10s
timeout: 5s
retries: 5
volumes:
data:

=======================================
command to run
docker-compose -f ./docker-compose-postgres.yml up

ERROR

Creating postgres … done
Creating nakama … done
Attaching to postgres, nakama
nakama | + /nakama/nakama migrate up --database.address postgres@postgres:5432/nakama
postgres | Error: Database is uninitialized and superuser password is not specified.
postgres | You must specify POSTGRES_PASSWORD to a non-empty value for the
postgres | superuser. For example, “-e POSTGRES_PASSWORD=password” on “docker run”.
postgres |
postgres | You may also use “POSTGRES_HOST_AUTH_METHOD=trust” to allow all
postgres | connections without a password. This is not recommended.
postgres |
postgres | See PostgreSQL documentation about “trust”:
postgres | https://www.postgresql.org/docs/current/auth-trust.html
postgres exited with code 1
nakama | {“level”:“info”,“ts”:“2020-07-25T03:13:28.112Z”,“msg”:“Database connection”,“dsn”:“postgres@postgres:5432/nakama”}
nakama | {“level”:“fatal”,“ts”:“2020-07-25T03:13:28.377Z”,“msg”:“Error pinging database”,“error”:“dial tcp: lookup postgres on 127.0.0.11:53: no such host”,“stacktrace”:“github.com/heroiclabs/nakama/migrate.Parse\n\t/go/src/github.com/heroiclabs/nakama/migrate/migrate.go:145\nmain.main\n\tmain.go:77\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:200”}

@kmsudhir That’s quite an old copy of the docker-compose file. You can always find the latest version of the file on the GitHub for the project:

https://github.com/heroiclabs/nakama/blob/master/docker-compose.yml

You can also use the Postgres version if you prefer:

https://github.com/heroiclabs/nakama/blob/master/docker-compose-postgres.yml

Hope that helps.

1 Like

The last docker-compose-postgres.yml file continue throw the same error as in topic:

Attaching to postgres, nakama
nakama      | + /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama
postgres    | The files belonging to this database system will be owned by user "postgres".
postgres    | This user must also own the server process.
postgres    | 
nakama      | {"level":"info","ts":"2021-12-01T16:25:14.471Z","caller":"migrate/migrate.go:181","msg":"Database connection","dsn":"postgres://postgres:xxxxx@postgres:5432/nakama?sslmode=prefer"}
postgres    | The database cluster will be initialized with locale "en_US.utf8".
nakama      | {"level":"fatal","ts":"2021-12-01T16:25:14.486Z","caller":"migrate/migrate.go:195","msg":"Failed to check if db exists","db":"nakama","error":"failed to connect to `host=postgres user=postgres database=nakama`: hostname resolving error (lookup postgres on 127.0.0.11:53: no such host)"}
postgres    | The default database encoding has accordingly been set to "UTF8".
postgres    | The default text search configuration will be set to "english".
postgres    | 
postgres    | Data page checksums are disabled.
postgres    | 
postgres    | initdb: directory "/var/lib/postgresql/data" exists but is not empty
postgres    | If you want to create a new database system, either remove or empty
postgres    | the directory "/var/lib/postgresql/data" or run initdb
postgres    | with an argument other than "/var/lib/postgresql/data".
postgres exited with code 1

Any idea how to solve this?

Hi @Insality welcome! could you post your issue as a new question, and did you grab the latest docker config for postgres from our docs? Docker compose - Heroic Labs Documentation

1 Like

Hello! Yea, I’ve tested the last postgres yml file from github master branch.

I tested it again before creating the new topic and it’s working! Didn’t know that changed, but currently there is no problem for me.

Note that from the your link the configuration have is pretty old Nakama version (3.2.1) instead of 3.9.0 on github.

Thank you for pointing that out. We’ve updated the version. I’m glad it’s working :slight_smile: