Video:

Running Postgres Locally with Docker

February 13, 2021

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now. Feel free to reach out to me on twitter - @Elliot_F

In the previous video in this course, we looked at how we could implement the transport package. Now, we are going to take a step back and look at how we can implement the storage layer of this service.

We need some form of storage system to store all of the comments from our incredible users. Since we know what the structure of our comments will look like, a SQL database is ideal for our situation. As such, we’ll be using Postgres to store everything.

Postgres has been around, basically forever and it is used in a huge variety of different situations.

Let’s start off by getting a docker instance up and running locally using docker.

Let’s open up the terminal and run the following command:

docker run --name some-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres

Once we’ve executed this, we should be able to see our container running using the docker ps command.

Awesome, we now have a locally running Postgres database we can now build our application against.