【发布时间】:2019-03-16 19:33:21
【问题描述】:
我在 Windows 10 计算机上运行 Postgres,我想从 Docker 容器连接到它。我遵循了许多来源的说明,并且事情应该正常工作,但它们没有。
用于创建 Docker 容器的命令行:
docker run --rm -d --network=host --name mycontainer myimage
在postgresql.conf:
listen_addresses = '*'
在pg_hba.conf:
host all all 172.17.0.0/16 trust
在容器的 bash shell 中,我运行:
psql -h 127.0.0.1
我得到了错误:
psql:无法连接到服务器:连接被拒绝
服务器是否在主机“127.0.0.1”上运行并接受端口 5432 上的 TCP/IP 连接?
不用说,Postgres 肯定在我的计算机上运行,我可以从本地应用程序中查询它。我错过了什么?
【问题讨论】:
标签: postgresql docker docker-for-windows