There are many ways to run a local instance of PostgreSQL databases, including installing a local instance of the SQL engine and running the SQL engine as a container instance. The advantages of running a PostgreSQL engine out of a container include having minimal to no configurations at setup and having the ability to run multiple engine versions of PostgreSQL.

The following command will start docker container running PostgresSQL (source):

docker run -d -p 5432:5432 --name my-postgres -e POSTGRES_PASSWORD=[server_password] postgres
docker exec -it my-postgres bash

PostgresSQL also comes with a compatible IDE known as "Pgadmin",  the IDE is a web-based application that allows you to connect to the PostgresSQL engine database.  the application is run from a container:

docker run -p 8888:80 -e "PGADMIN_DEFAULT_EMAIL=admin@email.com" -e "PGADMIN_DEFAULT_PASSWORD=password" -d dpage/pgadmin4

After, there should be two containers running, one for PostgresSQL and another for "pgadmin" IDE application.  The next step in to find out the IP of the container running PostgresSQL, you will need this to connect to the container from the local machine.

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [container_id]
Image showing docker ps command results and docker inspect to isolate the IP

Login into "pgadmin" by navigating to the web application. Use the container IP address, username, and password to connect into PostgresSQL.

A screen from "pgadmin" screen used to connect to a local container running PostgresSQL.

Connecting form local machine ...

We will be using nodeJS and the following script to test the newly created PostgresSQL container.  We will do this using a npm package known as "node-postgres" (source)

const { Client } = require('pg')
const client = new Client({
user: 'postgres',
host: 'localhost',
database: 'postgres',
password: '[server_password]',
port: 5432,});
client.connect();
client.query('SELECT NOW()', (err, res) => {  console.log(err, res)  client.end()});