Docker部署postgresql-11

1.docker pull docker.io/postgres:11

2.啓動命令腳本

vi startPostgres.sh

填入以下內容:

docker run -d --name postgresql-11 \
--restart=always  \
-v /postgresql/data:/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=123456 \
-p 5432:5432 \
docker.io/postgres:11

3.給腳本寫權限:

chmod +x startPostgres.sh

4.執行啓動腳本:

./startPostgres.sh

5.查看日誌,啓動報錯:

docker logs postgresql-11

2019-06-13 12:35:21.977 UTC [1] FATAL:  configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors
2019-06-13 12:35:23.182 UTC [1] LOG:  invalid value for parameter "lc_messages": "zh_CN.UTF-8"
2019-06-13 12:35:23.182 UTC [1] LOG:  invalid value for parameter "lc_monetary": "zh_CN.UTF-8"
2019-06-13 12:35:23.182 UTC [1] LOG:  invalid value for parameter "lc_numeric": "zh_CN.UTF-8"
2019-06-13 12:35:23.182 UTC [1] LOG:  invalid value for parameter "lc_time": "zh_CN.UTF-8"

6.在容器中安裝中文編碼:

>>docker exec -it postgresql-11 /bin/bash

1、root@9a36f3d4c0e9:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

2、debian下安裝 locale 並設置 zh_CN.UTF-8
root@9a36f3d4c0e9:/# apt-get install locales
Reading package lists... Done
Building dependency tree
Reading state information... Done
locales is already the newest version (2.24-11+deb9u4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


3、root@9a36f3d4c0e9:/# dpkg-reconfigure locales
Locales to be generated: 468
Default locale for the system environment: 3

Generating locales (this might take a while)...
  zh_CN.UTF-8... done
Generation complete.

7.重啓動docker容器:

doker start postgresql-11

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章