当前位置:网站首页>docker安装postgresSQL和设置自定义数据目录
docker安装postgresSQL和设置自定义数据目录
2022-07-31 05:09:00 【hunheidaode】
一、docker的安装
这里使用的是linux centos7以上的版本作为示例讲解
1、直接安装使用命令:yum install docker
2、启动命令:systemctl start docker
3、查询安装的docker版本信息:docker -version

4、指定版本拉取postgressql的镜像
docker pull postgres:10.9
5、使用docker images查询下载的镜像文件

二、接下来就是运行postgresSQL镜像的步骤了
1、先创建你要指定的数据目录:mkdir -p /home/pgdata
2、安装命令:docker run --name postgres -e POSTGRES_PASSWORD=bigAgent123456 -p 25432:5432 -v /home/pgdata:/var/lib/postgresql/data -d postgres:10.9
docker docker的命令
run 创建并运行一个容器
--name postgres 指定容器的名称
-e POSTGRES_PASSWORD=bigAgent123456 设置环境变量,指定数据库的用户名和密码,用户名为postgres,密码为:BigAgent123456
-p 25432:5432 指定端口:前面为映射的端口号,后面为镜像的端口号
-v /home/pgdata:/var/lib/postgresql/data 指定宿主机的目录和原数据目录
-d postgres:10.9 指定镜像名称以及版本号
PS:postgres镜像默认的用户名为postgres
3、创建完的docker容器
查询宿主机的端口:

如图端口便是我们指定的宿主机端口
4、如图便是安装成功,宿主机我们指定的数据目录文件夹:

三、测试
1、进入创建好的postgres容器命令:docker exec -it postgres bash

2、登录postgresSQL的命令:psql -h localhost -p 5432 -U postgres --password

3、至此我们docker安装postgresSQL就安装成功了,接下来,我们使用远程工程navicat.exe连接测试

四、更多学习资料请到
本文地址:CSDN
边栏推荐
- [Cloud Native] DevOps (5): Integrating Harbor
- .NET-6.WinForm2.NanUI learning and summary
- MySQL常见面试题汇总(建议收藏!!!)
- PCL calculates the point cloud coordinate maximum and its index
- TOGAF之架构标准规范(一)
- <urlopen error [Errno 11001] getaddrinfo failed>的解决、isinstance()函数初略介绍
- Unity resources management series: Unity framework how to resource management
- Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
- Create componentized development based on ILRuntime hot update
- 参考代码系列_1.各种语言的Hello World
猜你喜欢

Moment Pool Cloud quickly installs packages such as torch-sparse and torch-geometric

Mysql application cannot find my.ini file after installation

分布式事务处理方案大 PK!

Unity mobile game performance optimization series: performance tuning for the CPU side

Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
【一起学Rust】Rust的Hello Rust详细解析

Goodbye to the cumbersome Excel, mastering data analysis and processing technology depends on it

Mysql应用安装后找不到my.ini文件

Simple read operation of EasyExcel

Centos7 install mysql5.7 steps (graphical version)
随机推荐
[py script] batch binarization processing images
DVWA installation tutorial (understand what you don't understand · in detail)
ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
Unity Tutorial: URP Rendering Pipeline Practical Tutorial Series [1]
Centos7 install mysql5.7
Temporal线上部署
110道 MySQL面试题及答案 (持续更新)
Linux系统安装mysql(rpm方式安装)
城市内涝及桥洞隧道积水在线监测系统
MySQL transaction isolation level, rounding
Mysql application cannot find my.ini file after installation
SQL injection of DVWA
益智类游戏关卡设计:逆推法--巧解益智类游戏关卡设计
[C language] Detailed explanation of operators
mysql5.7.35安装配置教程【超级详细安装教程】
MySQL事务隔离级别详解
1. Get data - requests.get()
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
再见了繁琐的Excel,掌握数据分析处理技术就靠它了
MySQL8--Windows下使用压缩包安装的方法