当前位置:网站首页>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
边栏推荐
- TOGAF之架构标准规范(一)
- The 15th day of the special assault version of the sword offer
- Centos7 install mysql5.7
- ES source code API call link source code analysis
- ERP Production Operation Control Kingdee
- CentOS7 —— yum安装mysql
- Workflow番外篇
- Minesweeper game (written in c language)
- Apache DButils使用注意事项--with modifiers “public“
- 精解四大集合框架:List 核心知识总结
猜你喜欢

Sql解析转换之JSqlParse完整介绍

MySQL database installation (detailed)

ES 源码 API调用链路源码分析

为什么要用Flink,怎么入门使用Flink?
![[debug highlights] Expected input batch_size (1) to match target batch_size (0)](/img/b3/ff6ccc3cd307befad3bd07a9f4a956.png)
[debug highlights] Expected input batch_size (1) to match target batch_size (0)

MYSQL一站式学习,看完即学完

MySQL transaction isolation level, rounding

MySQL window function

The Vue project connects to the MySQL database through node and implements addition, deletion, modification and query operations

centos7安装mysql5.7
随机推荐
Pytorch教程Introduction中的神经网络实现示例
mysql uses on duplicate key update to update data in batches
Summary of MySQL common interview questions (recommended collection!!!)
Information System Project Manager Core Test Site (55) Configuration Manager (CMO) Work
Typec手机有线网卡网线转网口转接口快充方案
Unity Framework Design Series: How Unity Designs Network Frameworks
MySQL window function
Unity shader forge和自带的shader graph,有哪些优缺点?
110道 MySQL面试题及答案 (持续更新)
mysql stored procedure
【mysql 提高查询效率】Mysql 数据库查询好慢问题解决
sql语句之多表查询
MySQL开窗函数
.NET-9. A mess of theoretical notes (concepts, ideas)
限流的原理
sql statement - how to query data in another table based on the data in one table
Workflow番外篇
MySQL事务隔离级别详解
Centos7 install mysql5.7 steps (graphical version)
MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细