Preparing a PostgreSQL database

Like MongoDB, we will prepare a PostgreSQL instance for our CMS application. We will change our persistence layer to demonstrate how Spring Data abstracts it for developers. Then, we need to prepare a Docker Postgres instance for that.

We will use the version 9.6.6 of Postgres and use the alpine tag because it is smaller than other Postgres images. Let's pull our image. The command should be like this:

docker pull postgres:9.6.6-alpine

Then, wait until the download ends.

In the previous section, we created our Docker network called cms-application. Now, we will start our Postgres instance on that network as we did for MongoDB. The command to start the Postgres should be the following:

docker run -d --name postgres ...

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.