我有以下架构:
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也重新启动了。
问题可能是什么,如何诊断和可能的解决方案?你们当中有没有人经历过这种奇怪的码头行为?
发布于 2019-09-09 15:20:03
尝试使用标志--network host在托管网络中运行container_db
https://stackoverflow.com/questions/57849284
复制相似问题