官术网_书友最值得收藏!

  • Spring 5.0 By Example
  • Claudio Eduardo de Oliveira
  • 214字
  • 2021-06-24 19:17:40

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 --net cms-application -p 5432:5432 -e POSTGRES_PASSWORD=cms@springfive
postgres:9.6.6-alpine

The list of parameters is the same as we passed for MongoDB. We want to run it in background mode and attach it to our custom network. As we can see, there is one more new parameter in the docker run command. Let's understand it:

  • -e: This enables us to pass environment variables for a container. In this case, we want to change the password value.

Good job. We have done our infrastructure requirements. Let's understand the persistence details right now.

主站蜘蛛池模板: 宜章县| 临城县| 崇明县| 通辽市| 湖北省| 名山县| 横峰县| 仁怀市| 林西县| 台州市| 赤壁市| 蓬莱市| 永定县| 内黄县| 江西省| 凌源市| 元江| 吴旗县| 合作市| 南澳县| 东台市| 定州市| 碌曲县| 息烽县| 郑州市| 咸宁市| 仙游县| 宁夏| 宝清县| 霍山县| 乌兰察布市| 锡林浩特市| 和硕县| 三穗县| 定襄县| 平顶山市| 伊宁市| 南平市| 江安县| 垣曲县| 宁强县|