yo

Docker Postgres/SQL
Quick Start Guide

  • Jesse Madsen | October 13, 2022
  • 20 min

We will be installing Docker Desktop and spinning up a Postgres Database container. The installation time will vary, but the whole process should take less than 20 minutes.

  • First Part: Installing Docker Desktop
  • Second Part: Installing Postgres image/container.
  • Third Part: Installing DBever and Connecting to Postgres.

First Part: Install Docker Destop

Docker Desktop will allow us to manage our containers. If you are new to Docker, then you can check out Dockers excellent reference guide by clicking the docker whale below.

Blog Images

Install Docker Desktop by downloading from Docker.

Note you must have WSL 2 setup and working for Windows.

Once you have finished installing Docker Desktop it will not start automatically. Search for Docker Desktop in your Windows start-up menu and start it.

windows_startup



Sign in if prompted.

docker_signIn




Second Part: Installing Postgres image/container.

First we need to open a new Windows Powershell.

docker_signIn


Then we are going to paste in the following code, make sure Docker Desktop is running!
docker run -d -p 5432:5432 --name postgres-sample -e POSTGRES_PASSWORD=password --restart always postgres

There will be a container ID if you are succesful.

Blog Images

Your Docker Desktop will have a Postgres Instance running, mapped to port 5453.

Blog Images

Third Part: Installing DBever and Connecting to Postgres.

If you are not familiar with DBeaver, it is a free light weight universal database GUI interface. We will be able to connect to our new Postgress Database and run PostgresSQL query commands. Click DBeaver below to download.

DBeaver

After you install DBeaver, we need to set up a new connect to our Postgres Instance. Click File and Select New.

DBeaver

Dropdown options in the DBeaver folder and select the database connection, then Next.

DBeaver

Double click PostgresSQl.

DBeaver

Right click postgres-sample and Edit the Connection.

DBeaver

Setting and testing the connection we need to set/check three settings.

  • Database: postgres
  • Username: postgres
  • Password: password

DBeaver

Last step is to test connection. There will be a Connection test pop-up if you are succesful. Note, your Docker Destop needs to be on!

DBeaver

Thank you for following my blog. I hope it was informative and was able to help you spin up a brand new Postgres database. If you are interested in learning more on databases, you can click the below link "My first Database Tables."

Leave a Reply