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, but you can change this to whatever you like. Be sure to use the same name in all subsequent commands too if you do change it though.

docker volume…

Ocean Blue

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store