The command below can be used to spin up a Postgres database server instance for use with Waltz.
Set the default username and password using environment variables as in the command below.
POSTGRES_DB
is set to waltz
, so that the default database created by Postgres is named as waltz
.
Optional: Use -p 5432:5432
in the command to access your database server using the host machine's IP address.
By default, Docker manages data peristence by writing database files to disk on the host system. This is transparent to the user and data is preserved between container restarts (until the container is removed).
While this is sufficient for dev/test instances, it is recommended that you explore options like mounting directories onto the Postgres docker container to store data, backups etc.
More information on running Postgres in a Docker container can be found here: Postgres Docker Official Documentation
# run the database container in the background
[user@machine:waltz-docker]$ docker run -d \
--name waltz-db-postgres \
-e POSTGRES_USER=waltz \
-e POSTGRES_PASSWORD=waltz \
-e POSTGRES_DB=waltz \
postgres:10.6
Waltz maintainers provide sample data dumps for Postgres, which can be downloaded from the releases page and used to initialise your database.
- Download the
dump_pg_*.zip
file for the latest available release (data dumps from older releases will also work, as the build process will upgrade your database) - Extract the
.sql
file (ususally nameddump.sql
) from the zip - Copy the
dump.sql
file to thedatabase/postgres
directory - Run the command to create the database, using the
-v
option to mountdatabase/postgres
to the container's/docker-entrypoint-initdb.d
directory, so that Postgres can use thedump.sql
file to initialise yourwaltz
database
POSTGRES_USER
must be set topostgres
for the import to work correctly, as this is what thedump.sql
file uses
Make sure the Postgres version in the command below matches the version in
dump.sql
file (check the line containing: Dumped from database version)
This command must be run from the
waltz-docker
root directory
# run the database container in the background
[user@machine:waltz-docker]$ docker run -d \
--name waltz-db-postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=waltz \
-e POSTGRES_DB=waltz \
-v "${PWD}"/database/postgres:/docker-entrypoint-initdb.d \
postgres:10.6
# pass the username used when creating the DB in the -U option
# docker exec -it <container_name> psql -d <db_name> -U <user_name>
# use the password set above when prompted
[user@machine:waltz-docker]$ docker exec -it waltz-db-postgres psql -d waltz -U waltz
or
[user@machine:waltz-docker]$ docker exec -it waltz-db-postgres psql -d waltz -U postgres
[user@machine:waltz-docker]$ docker exec waltz-db-postgres hostname -I