Skip to content

Configure local PostgreSQL with Docker

Thibaut Bremand edited this page May 2, 2020 · 3 revisions

In this page, you'll learn how to launch a basic PostgreSQL instance and use it with 2D-MMORPG.

1/ Configure PostgreSQL

We are going to use this image.
In this example, we will keep the default database postgres and the default user postgres.

Pull the image:

  • docker pull postgres

Launch a basic PostgreSQL instance, and expose its port to the local port 5432:

  • docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Go to the PostgreSQL CLI:

  • docker exec -it some-postgres psql -U postgres

If you need to load a PostgreSQL dump into your Docker PostgreSQL instance:

  • docker exec -i some-postgres psql -U postgres -d postgres < yourdbexport.sql

You don't need to create any specific tables for 2D-MMORPG as the server will automatically create them into the database when it's launched.

2/ Configure the environment variables

With the example above, you can fill your .env file as such:
DB_NAME=postgres
DB_PASS=mysecretpassword
DB_USER=postgres
DB_HOST=localhost
DB_PORT=5432

Clone this wiki locally