Compose and run a local docker postgreSQL DB instance where you can create new databases in order to develop on local.
This project also has a dump and restore instructions to easily dump a db and also create a restore data into a DB instance on docker on dump_restore_postgres folder.
Get into postgres folder
cd postgres
There is a docker-compose file inside postgres postgres/docker-compose.yml Inside this file you can see all the configurations to run a docker postgres instance
container_name: postgres-docker-instance
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD={any_password}
If you have a local instance of postgres running on local probably your port 5432 is used, in that case you can put another port as inside port meanwhile the extern port must be always 5432
inside:extern
ports:
- "5433:5432"
Open a new terminal on postgres folder a run docker
docker-compose up
After this you can connect the DB using a DB Manager like dbeaver
https://dbeaver.io
In order to use postgres command like psql you have the following format:
docker exec <container_name> psql -U <postgres_user> -c "CREATE DATABASE <db_name>;"
docker exec <container_name> psql -U <postgres_user> -l