第二十九章 Centos7下Docker安装Postgresql
2022/1/24 19:06:09
本文主要是介绍第二十九章 Centos7下Docker安装Postgresql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、拉取Postgresql镜像文件
[root@m1 ~]# docker pull postgres:latest
二、创建挂载目录并授权
[root@m1 ~]# mkdir -p /data/pgdata
三、创建并启动Postgresql容器
[root@m1 ~]# docker run \ -itd \ -p 5432:5432 \ -v /data/pgdata:/var/lib/postgresql/data \ -v /etc/localtime:/etc/localtime \ -e POSTGRES_PASSWORD=123456 \ --restart always \ --privileged=true \ --name my_postgres \ postgres:latest
四、查看Postgresql是否启动成功
[root@m1 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a2a1681b11a9 postgres:latest "docker-entrypoint.s…" 9 seconds ago Up 8 seconds 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp my_postgres
五、查看docker容器日志
[root@m1 ~]# docker logs my_postgres PostgreSQL Database directory appears to contain a database; Skipping initialization 2022-01-24 14:53:00.365 CST [1] LOG: starting PostgreSQL 14.1 (Debian 14.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit 2022-01-24 14:53:00.365 CST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2022-01-24 14:53:00.365 CST [1] LOG: listening on IPv6 address "::", port 5432 2022-01-24 14:53:00.368 CST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2022-01-24 14:53:00.374 CST [27] LOG: database system was interrupted; last known up at 2022-01-24 14:48:27 CST 2022-01-24 14:53:00.390 CST [27] LOG: database system was not properly shut down; automatic recovery in progress 2022-01-24 14:53:00.392 CST [27] LOG: redo starts at 0/16FAB48 2022-01-24 14:53:00.392 CST [27] LOG: invalid record length at 0/16FAB80: wanted 24, got 0 2022-01-24 14:53:00.393 CST [27] LOG: redo done at 0/16FAB48 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s 2022-01-24 14:53:00.405 CST [1] LOG: database system is ready to accept connections
六、拉取pgadmin4工具镜像
[root@m1 ~]# docker pull dpage/pgadmin4:latest
七、创建并启动pgadmin4容器
[root@m1 ~]# docker run \ -itd \ -p 5080:80 \ -v /etc/localtime:/etc/localtime \ -e PGADMIN_DEFAULT_EMAIL=hui.jin@dataxgroup.com \ -e PGADMIN_DEFAULT_PASSWORD=123456 \ --restart always \ --privileged=true \ --name pgadmin \ dpage/pgadmin4
八、查看pgadmin4是否启动成功
[root@m1 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eed7a36f995e dpage/pgadmin4 "/entrypoint.sh" 7 seconds ago Up 4 seconds 443/tcp, 0.0.0.0:5080->80/tcp, :::5080->80/tcp pgadmin a2a1681b11a9 postgres:latest "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp my_postgres
九、验证连接
#1.登录pgadmin4,输入启动容器时的邮箱和密码即可
#2.创建新的service连接,连接host:192.168.13.200,默认的用户名为postgres,点击保存即可看到连接成功。
这篇关于第二十九章 Centos7下Docker安装Postgresql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-20Docker部署资料:新手入门教程
- 2024-12-19Docker部署实战:新手入门教程
- 2024-12-19Docker部署教程:新手入门详解
- 2024-12-09云原生周刊:在Docker上部署大语言模型
- 2024-12-05Docker教程:新手快速入门指南
- 2024-12-05Docker项目实战:新手教程与案例解析
- 2024-12-04Docker入门教程:快速掌握基础操作
- 2024-12-04Docker入门教程:轻松搭建你的第一个容器化应用
- 2024-12-04Docker-Compose 入门教程:全面解析基础命令与应用场景
- 2024-12-04Docker入门:新手必读的简单教程