当前位置:网站首页>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
边栏推荐
- 110道 MySQL面试题及答案 (持续更新)
- ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
- The Vue project connects to the MySQL database through node and implements addition, deletion, modification and query operations
- a different object with the same identifier value was already associated with the session
- Minio upload file ssl certificate is not trusted
- 对list集合进行分页,并将数据显示在页面中
- Input length must be multiple of 8 when decrypting with padded cipher
- MYSQL下载及安装完整教程
- 再见了繁琐的Excel,掌握数据分析处理技术就靠它了
- MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细
猜你喜欢
MySQL优化:从十几秒优化到三百毫秒
面试官,不要再问我三次握手和四次挥手
Unity框架设计系列:Unity 如何设计网络框架
分布式事务——分布式事务简介、分布式事务框架 Seata(AT模式、Tcc模式、Tcc Vs AT)、分布式事务—MQ
Multiple table query of sql statement
Sun Wenlong, Secretary General of the Open Atom Open Source Foundation |
MySQL transaction (transaction) (this is enough..)
Sql解析转换之JSqlParse完整介绍
Apache DButils使用注意事项--with modifiers “public“
MySQL forgot password
随机推荐
一文了解大厂的DDD领域驱动设计
110道 MySQL面试题及答案 (持续更新)
Goodbye to the cumbersome Excel, mastering data analysis and processing technology depends on it
ERROR 2003 (HY000) Can't connect to MySQL server on 'localhost3306' (10061)
Numpy中np.meshgrid的简单用法示例
Linux系统安装mysql(rpm方式安装)
SQL行列转换
分布式事务处理方案大 PK!
ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
有了MVC,为什么还要DDD?
Mysql——字符串函数
[py script] batch binarization processing images
MySQL事务(transaction) (有这篇就足够了..)
CentOS7 install MySQL graphic detailed tutorial
【LeetCode-SQL每日一练】——2. 第二高的薪水
Go language study notes - dealing with timeout problems - Context usage | Go language from scratch
MySQL事务隔离级别详解
Pytorch教程Introduction中的神经网络实现示例
ABC D - Distinct Trio (Number of k-tuples
centos7安装mysql5.7步骤(图解版)