docker postgres pgadmin 本地连​​接 [英] docker postgres pgadmin local connection

查看:31
本文介绍了docker postgres pgadmin 本地连​​接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 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 inspector 尝试使用图像 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:

  1. 从 Docker Hub 拉取 postgres 镜像

  1. Pull postgres image from Docker Hub

docker pull postgres:latest

  • 使用以下命令运行容器

  • Run the container using the below command

    docker run -p 5432:5432 postgres
    

  • 使用docker的inspect命令查找IP

  • Using docker's inspect command find the IP

    使用该 IP、端口、用户名和密码在 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆