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

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.

主站蜘蛛池模板: 山丹县| 东阿县| 泸州市| 陵水| 林芝县| 安岳县| 偃师市| 九寨沟县| 建宁县| 马山县| 白银市| 福建省| 田阳县| 洪雅县| 南川市| 故城县| 商丘市| 台江县| 乐昌市| 杨浦区| 蚌埠市| 县级市| 罗江县| 石渠县| 赣州市| 林西县| 西盟| 新兴县| 无棣县| 玛纳斯县| 右玉县| 苍山县| 恩施市| 沙湾县| 万安县| 微山县| 眉山市| 远安县| 泾川县| 广水市| 鄂伦春自治旗|