首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker容器,运行PostgreSQL不允许来自其他容器的php的pg_connect

Docker容器,运行PostgreSQL不允许来自其他容器的php的pg_connect
EN

Stack Overflow用户
提问于 2019-09-09 15:09:07
回答 1查看 163关注 0票数 0

我有以下架构:

代码语言:javascript
复制
A network with 3 containers:
    container_db, running PostgreSQL
    container_pg_admin, running a simple pgAdmin environment
    container_php_dev, running the whole environment, needed for the application to function properly (nginx, php, angular for the frontend, etc.)

当我尝试从container_php_dev pg_connect()到container_db时,连接被拒绝。这是我得到的实际错误消息:pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: No route to host↵ Is the server running on host "container_db" (172.18.0.4) and accepting↵ TCP/IP connections on port 5432?

然而,当我尝试从container_pg_admin连接到container_db时,我没有遇到任何问题(主机是container_db,端口是5432)。即使我将container_db的端口5432映射到主机上的5555,我也能够从DBeaver或其他数据库管理器(TeamSQL)连接到127.0.0.1:5555。

所有的容器以及docker本身都被重启了几次。因为这是我的开发机器,所以主机PC也重新启动了。

问题可能是什么,如何诊断和可能的解决方案?你们当中有没有人经历过这种奇怪的码头行为?

EN

回答 1

Stack Overflow用户

发布于 2019-09-09 15:20:03

尝试使用标志--network host在托管网络中运行container_db

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57849284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档