In some cases you might want to have postgres setup on your machine. Let us understand how we can setup Postgres using Docker.
If you are using our labs, the database will be pre-created by us with all the right permissions.
If you are using Windows or Mac, ensure that you have installed Docker Desktop.
If you are using Ubuntu based desktop, make sure to setup Docker.
Here are the steps that can be used to setup Postgres database using Docker.
Pull the postgres image using
Create the container using
Start the container using
Alternatively we can use
docker run which will pull, create and start the container.
docker logs or
docker logs -f to review the logs to ensure Postgres Server is up and running.
You can connect to Postgres Database setup using Docker with
You can also connecto to Postgres directly with out using
psql -h localhost -p 5433 -d postgres -U postgres -W