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 docker pull
Create the container using docker create
.
Start the container using docker start
.
Alternatively we can use docker run
which will pull, create and start the container.
Use 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 docker exec
.
You can also connecto to Postgres directly with out using docker exec
.
psql -h localhost
-p 5433
-d postgres
-U postgres
-W