当前位置:网站首页>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
边栏推荐
- Simple read operation of EasyExcel
- 快速掌握并发编程 --- 基础篇
- matlab abel变换图片处理
- 关于LocalDateTime的全局返回时间带“T“的时间格式处理
- Numpy中np.meshgrid的简单用法示例
- Goodbye to the cumbersome Excel, mastering data analysis and processing technology depends on it
- 【JS面试题】面试官:“[1,2,3].map(parseInt)“ 输出结果是什么?答上来就算你通过面试
- 限流的原理
- Workflow番外篇
- Sun Wenlong, Secretary General of the Open Atom Open Source Foundation |
猜你喜欢

MySQL database backup

STM32——DMA

Sun Wenlong, Secretary General of the Open Atom Open Source Foundation |

CentOS7 安装MySQL 图文详细教程

Apache DButils使用注意事项--with modifiers “public“
![[R language] [3] apply, tapply, lapply, sapply, mapply and par function related parameters](/img/98/282d8d192f701ad33de48aeeb038b4.png)
[R language] [3] apply, tapply, lapply, sapply, mapply and par function related parameters

Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
![Unity Tutorial: URP Rendering Pipeline Practical Tutorial Series [1]](/img/7c/c9ab32bbf43b933e5f84f0d142f7bd.jpg)
Unity Tutorial: URP Rendering Pipeline Practical Tutorial Series [1]

On-line monitoring system for urban waterlogging and water accumulation in bridges and tunnels

Interview | Cheng Li, CTO of Alibaba: Cloud + open source together form a credible foundation for the digital world
随机推荐
Go language study notes - dealing with timeout problems - Context usage | Go language from scratch
110道 MySQL面试题及答案 (持续更新)
Sun Wenlong, Secretary General of the Open Atom Open Source Foundation |
有了MVC,为什么还要DDD?
datagrip带参sql查询
Doris学习笔记之监控
【一起学Rust】Rust的Hello Rust详细解析
Three oj questions on leetcode
MySQL forgot password
Linux的mysql报ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘ (using password NOYSE)
MySQL database addition, deletion, modification and query (detailed explanation of basic operation commands)
Unity URP渲染管线摄像机核心机制剖析
Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
sql statement - how to query data in another table based on the data in one table
DVWA shooting range environment construction
矩池云快速安装torch-sparse、torch-geometric等包
Simple read operation of EasyExcel
SQL语句中对时间字段进行区间查询
.NET-6.WinForm2.NanUI learning and summary
Centos7 install mysql5.7 steps (graphical version)