Create a Postgres Database from scratch in 5 minutes

Prerequisite: The article assume you know Postgres and Docker. To learn more about Docker, please feel free to check out my Docker series.

Create a Docker volume as data storage

Docker containers don’t have permanent storage, so we’ll start by creating a Docker volume. This makes it easier to destroy and launch a new Postgres container without losing your database data.

Run the following command to create a Docker volume. Note that the example uses the name pgdata