[root@localhost ~]# docker pull postgres
Using default tag: latest
latest: Pulling from library/postgres
27833a3ba0a5: Pull complete
ed00742830a6: Pull complete
dc611c2aceba: Pull complete
a61becab5279: Pull complete
8dcff41e7aea: Pull complete
820bf1bbf0d7: Pull complete
050804429905: Pull complete
782c81275334: Pull complete
bfb4aaa36ad6: Pull complete
9101c497b579: Pull complete
746ef6cad24f: Pull complete
0b3454d86d65: Pull complete
446fd78a7de2: Pull complete
b22ef7f366b5: Pull complete
Digest: sha256:e002abfaf7b0f1015b7510f66b709e2bacbecc7762c428634c27a3c5e58ffbae
Status: Downloaded newer image for postgres:latest
[root@localhost ~]# docker run --name cluster1 -p 5454:5432 -e POSTGRES_PASSWORD=postgres -d postgres
2ea3471c99cf1cc1ab4bde63011cdee0427c44b037d546ccfceaa38640ff18fb
[root@localhost ~]# docker run --name cluster2 -p 5455:5432 -e POSTGRES_PASSWORD=postgres -d postgres
cf982bed6db338611c2b5620dcd8023c1f48a9d3cd6bcfbe97db1306c6d8babc
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cf982bed6db3 postgres "docker-entrypoint.s…" 3 seconds ago Up 2 seconds 0.0.0.0:5455->5432/tcp cluster2
2ea3471c99cf postgres "docker-entrypoint.s…" 10 seconds ago Up 9 seconds 0.0.0.0:5454->5432/tcp cluster1
[root@localhost ~]# docker inspect cf982bed6db3 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.3",
"IPAddress": "172.17.0.3",
[root@localhost ~]# docker inspect 2ea3471c99cf | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
[root@localhost ~]# sudo yum install postgresql-server postgresql-contrib
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 postgresql-contrib.x86_64.0.9.2.18-1.axs7 将被 安装
--> 正在处理依赖关系 postgresql-libs(x86-64) = 9.2.18-1.axs7,它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 postgresql(x86-64) = 9.2.18-1.axs7,它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 libxslt.so.1(LIBXML2_1.0.22)(64bit),它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 libxslt.so.1(LIBXML2_1.0.18)(64bit),它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 libxslt.so.1(LIBXML2_1.0.11)(64bit),它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 libxslt.so.1()(64bit),它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 libpq.so.5()(64bit),它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
--> 正在处理依赖关系 libossp-uuid.so.16()(64bit),它被软件包 postgresql-contrib-9.2.18-1.axs7.x86_64 需要
---> 软件包 postgresql-server.x86_64.0.9.2.18-1.axs7 将被 安装
--> 正在检查事务
---> 软件包 libxslt.x86_64.0.1.1.28-5.axs7 将被 安装
---> 软件包 postgresql.x86_64.0.9.2.18-1.axs7 将被 安装
---> 软件包 postgresql-libs.x86_64.0.9.2.18-1.axs7 将被 安装
---> 软件包 uuid.x86_64.0.1.6.2-26.axs7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==========================================================================================================================================================
Package 架构 版本 源 大小
==========================================================================================================================================================
正在安装:
postgresql-contrib x86_64 9.2.18-1.axs7 redflag-base 551 k
postgresql-server x86_64 9.2.18-1.axs7 redflag-base 3.8 M
为依赖而安装:
libxslt x86_64 1.1.28-5.axs7 redflag-base 241 k
postgresql x86_64 9.2.18-1.axs7 redflag-base 3.0 M
postgresql-libs x86_64 9.2.18-1.axs7 redflag-base 232 k
uuid x86_64 1.6.2-26.axs7 redflag-base 55 k
事务概要
==========================================================================================================================================================
安装 2 软件包 (+4 依赖软件包)
总下载量:7.8 M
安装大小:35 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): libxslt-1.1.28-5.axs7.x86_64.rpm | 241 kB 00:00:00
(2/6): postgresql-contrib-9.2.18-1.axs7.x86_64.rpm | 551 kB 00:00:01
(3/6): postgresql-libs-9.2.18-1.axs7.x86_64.rpm | 232 kB 00:00:00
(4/6): postgresql-9.2.18-1.axs7.x86_64.rpm | 3.0 MB 00:00:09
(5/6): uuid-1.6.2-26.axs7.x86_64.rpm | 55 kB 00:00:00
(6/6): postgresql-server-9.2.18-1.axs7.x86_64.rpm | 3.8 MB 00:00:09
----------------------------------------------------------------------------------------------------------------------------------------------------------
总计 690 kB/s | 7.8 MB 00:00:11
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : postgresql-libs-9.2.18-1.axs7.x86_64 1/6
正在安装 : postgresql-9.2.18-1.axs7.x86_64 2/6
正在安装 : libxslt-1.1.28-5.axs7.x86_64 3/6
正在安装 : uuid-1.6.2-26.axs7.x86_64 4/6
正在安装 : postgresql-contrib-9.2.18-1.axs7.x86_64 5/6
正在安装 : postgresql-server-9.2.18-1.axs7.x86_64 6/6
验证中 : postgresql-contrib-9.2.18-1.axs7.x86_64 1/6
验证中 : postgresql-server-9.2.18-1.axs7.x86_64 2/6
验证中 : uuid-1.6.2-26.axs7.x86_64 3/6
验证中 : postgresql-libs-9.2.18-1.axs7.x86_64 4/6
验证中 : postgresql-9.2.18-1.axs7.x86_64 5/6
验证中 : libxslt-1.1.28-5.axs7.x86_64 6/6
已安装:
postgresql-contrib.x86_64 0:9.2.18-1.axs7 postgresql-server.x86_64 0:9.2.18-1.axs7
作为依赖被安装:
libxslt.x86_64 0:1.1.28-5.axs7 postgresql.x86_64 0:9.2.18-1.axs7 postgresql-libs.x86_64 0:9.2.18-1.axs7 uuid.x86_64 0:1.6.2-26.axs7
完毕!
[root@localhost ~]# psql -h172.17.0.3 -Upostgres -p5432
用户 postgres 的口令:
psql: fe_sendauth: no password supplied
[root@localhost ~]# psql -h172.17.0.3 -Upostgres -ppostgres
psql: 无效端口号: "postgres"
[root@localhost ~]# psql -h172.17.0.3 -Upostgres -p5432
用户 postgres 的口令:postgres
postgres=# \l
资料库列表
名称 | 拥有者 | 字元编码 | 校对规则 | Ctype | 存取权限
-----------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 行记录)
postgres=# \q
[root@localhost ~]# ip addr | grep 192.168
inet 192.168.229.130/24 brd 192.168.229.255 scope global dynamic ens33
[root@localhost ~]# psql -h192.168.229.130 -p5455 -Upostgres
用户 postgres 的口令:postgres
postgres=# \q
[root@localhost ~]#