当前位置:网站首页>docker安装postgresql
docker安装postgresql
2022-06-22 12:19:00 【抹香鲸之海】
查询postgresql镜像
docker search postgres

NAME --镜像名称
DESCRIPTION --镜像描述
STARS --标星数
OFFICIAL --官方的
AUTOMATED -- 自动化
拉去镜像文件
docker pull postgres:12.3
制作容器
docker run --name postgres -e POSTGRES_PASSWORD=123456 -p 5432:5432 -v /home/postgresql/pgdata:/var/lib/postgresql/data -d postgres:12.3
run :创建并运行一个容器;
–name :指定容器名称。(容器名称 自己设置)
-e POSTGRES_PASSWORD=password,设置环境变量,指定数据库的登录口令为password(password 自己设置)
-p :指定宿主机和 Docker 容器端口映射,冒号前为宿主机端口号,另一个是容器端口号。(Docker的容器默认情况下只能由本地主机访问,即A主机上的容器不能被B主机访问,所以要做端口映射)(端口号 自己设置)
-d postgres:12.3:指定使用postgres:12.3作为镜像
查看容器

进入容器创建角色
docker exec -it e43e247b1ed4 bash
切换用户
su postgres

创建sonar用户

链接
psql

创建sonar数据库
create database sonar owner=sonar;

查看数据库
\l

至此,sonar用户与数据库均已创建成功,并且数据库中的数据持久化在宿主机中,方便下次访问及做备份。
可视化链接工具
链接一下

远程链接报错:
Connection to 120.48.54.67:5040 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Connection refused: connect
Connection refused: connect
这语句翻译下,用户名密码是正确的,但是tcp/ip的连接失败了。这个解决方法其实就是去建立tcp/ip连接过程。
原因是宿主机并没有监听其他的主机接口,因此没有建立连接。
修改配置文件:
进入postgres容器内部 修改/var/lib/pgsql/9.6/data/postgresql.conf (也可以修改挂载目录里面的文件)
新增listen_addresses = ‘*’
#what IP address(es) to listen on
#默认 listen_addresses = ‘localhost’

链接成功!
边栏推荐
- Isn't the execution process of ODPs SQL executed from top to bottom
- Getenv, setenv functions (get and set system environment variables) and environment variables
- XML file parsed by repo
- universaldependencies依存关系标签解释
- 帝云CMS升级PHP8注意事项
- Flutter之CustomPaint 绘制贝塞尔曲线图表(三)
- [QT] QT get standard system path
- Repair flutter_ webview_ The problem of web layer residue when the plugin slides out of the page
- How to improve customer conversion rate on the official website
- Sliding conflict handling effect of cloud music imitating Netease
猜你喜欢

Tianyi cloud digital government smart data center has passed the certification

0007 reverse integer

SAP-ABAP-BAPI_GOODSMVT_CREATE创建物料凭证bapi的各种情况如何赋值

Flutter&Flame——TankCombat游戏手柄开发(一)

Sliding conflict handling effect of cloud music imitating Netease

Flutter version Parallax effect of Zhihu list

Recommend a virtual machine software for fast cluster building of M1 chip computers

Final of the 12th Blue Bridge Cup embedded design and development project

SAP development keys application SSCR keys application

推荐一款M1芯片电脑快速搭建集群的虚拟机软件
随机推荐
8 challenges of BSS application cloud native deployment
Flutter 仿Airbnb的价格区间筛选器。(二)
Terraform的vpc网络自动化配置解决方案
Flutter imitates airbnb's price range filter. (I)
Isn't this another go bug?
SAP-MM-MIGO 311工厂内转移挑拨库存
Final of the 11th Blue Bridge Cup embedded design and development project
Es aggregation details
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
In depth analysis of glide source code
What is C language structure byte alignment and why?
Jushan database was invited to attend Kunpeng developers' annual event 2022 to jointly build a domestic digital base
Sap-abap- how to transfer material master data, supplier master data, work orders, purchase orders and other information to external systems in real time - implicit enhancement.
Lao Wang said that the sixth issue of the series: PHP programmers should build their own self-confidence
SAP ABAP ole core code
Flutter:剥离StatefulWidget——简化页面开发、跳转以及传值
The solution of VPC network automatic configuration based on terraform
On the routing tree of gin
SNC processing failed SAP Router证书重新生成
MySQL_ Create and manage tables