docker postgres pgadmin本地连接 [英] docker postgres pgadmin local connection
问题描述
我已经用nginx,php和postgres创建了一个ubuntu映像。
I have created an ubuntu image with nginx, php and postgres.
我想将我当前图像中的postgres数据库连接到 pgadmin
位于我的本地机器上。
I want to connect the postgres database in my current image with pgadmin
located on my local machine.
我已尝试使用docker检查器尝试使用图像ip与本地的pgadmin建立连接,但没有太多的成功。我也尝试在本地配置一些端口,使连接工作。
I have tried using docker inspector to try to use the image ip to make a connection with my local pgadmin but without much success. I've also tried configuring some ports on local to make connection work.
推荐答案
这是一个有效的问题,不知道为什么人们感觉似乎不可能回答这个问题。
It's a valid question don't know why people feel "doesn't seem possible to answer that question".
所以,以下是我如何做你想做的:
So, here's how I do what you are trying to do:
-
从Docker Hub拉出Postgres图片
Pull postgres image from Docker Hub
docker pull postgres:latest
docker pull postgres:latest
使用以下命令运行容器
docker运行-p 5432:5432 postgres
使用docker的inspect命令查找IP
Using docker's inspect command find the IP
使用该IP,PORT,用户名和密码连接PGADMIN
Use that IP, PORT, Username, and Password to connect in PGADMIN
您还可以像下面这样简单的telnet确认您是否可以访问docker postgres容器:
You can also do a simple telnet like below to confirm if you can access docker postgres container:
telnet IP_ADDRESS 5432
这篇关于docker postgres pgadmin本地连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!