当前位置:网站首页>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
边栏推荐
- Information System Project Manager Core Test Site (55) Configuration Manager (CMO) Work
- 【一起学Rust】Rust的Hello Rust详细解析
- centos7安装mysql5.7
- 参考代码系列_1.各种语言的Hello World
- .NET-9. A mess of theoretical notes (concepts, ideas)
- STM32——DMA
- MySQL事务(transaction) (有这篇就足够了..)
- DVWA安装教程(懂你的不懂·详细)
- a different object with the same identifier value was already associated with the session
- MySQL window function
猜你喜欢

MySQL-Explain详解

DVWA之SQL注入

Distributed Transactions - Introduction to Distributed Transactions, Distributed Transaction Framework Seata (AT Mode, Tcc Mode, Tcc Vs AT), Distributed Transactions - MQ

面试官竟然问我怎么分库分表?幸亏我总结了一套八股文

ERP Production Operation Control Kingdee

Redis进阶 - 缓存问题:一致性、穿击、穿透、雪崩、污染等.

centos7安装mysql5.7

有了MVC,为什么还要DDD?

A complete introduction to JSqlParse of Sql parsing and conversion

Unity教程:URP渲染管线实战教程系列【1】
随机推荐
Pytorch教程Introduction中的神经网络实现示例
【LeetCode-SQL每日一练】——2. 第二高的薪水
Reference code series_1. Hello World in various languages
ERROR 1819 (HY000) Your password does not satisfy the current policy requirements
Centos7 install mysql5.7 steps (graphical version)
ABC D - Distinct Trio(k元组的个数
Linux的mysql报ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘ (using password NOYSE)
sql语句-如何以一个表中的数据为条件据查询另一个表中的数据
对list集合进行分页,并将数据显示在页面中
MySQL transaction (transaction) (this is enough..)
Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
Go language study notes - dealing with timeout problems - Context usage | Go language from scratch
MySQL忘记密码怎么办
The monitoring of Doris study notes
mysql使用on duplicate key update批量更新数据
DVWA安装教程(懂你的不懂·详细)
MySQL优化之慢日志查询
[R language] [3] apply, tapply, lapply, sapply, mapply and par function related parameters
可点击也可直接复制指定内容js
MySQL forgot password