Running Postgres Locally with Docker

This video goes through each step and explains a few things along the way.

Step 1 - Install Docker

If you haven’t already, visit docker.com and download the desktop application for your OS.

The beauty of Docker is that it allows you to run software without dealing with a ton of OS or dependency headaches!

Step 2 - Run a PostgreSQL docker container

The following command will download and run a docker image containing PostgreSQL 13.1 locally.

docker container run --name postgresdb -p 5432:5432 -v pgdata -e POSTGRES_PASSWORD='mypass12345' postgres:13.1

Let’s break it down:

Step 3 - Connect to PostgreSQL

At this point, if you have PSQL on your computer, you can connect to the database by using PSQL.

We’re going to go inside the Docker container first - it makes it so we don’t have to install anything else on our computer.

Open another tab in your command line client and run:

docker exec -it postgresdb psql -U postgres

Let’s break that one down:

Step 4 - Do some data stuff!

That’s it! Hope this helps you. Click here to check out the next video where we will spin up a PostgreSQL database in the cloud on AWS!