2015-09-22 33 views
0

我使用Postgres的:9.3泊坞窗容器从官方泊坞窗枢纽如何让postgresql数据库从postgres docker容器的外部连接起来?

https://hub.docker.com/_/postgres/ 

启动数据库容器命令

docker run -d -e POSTGRES_PASSWORD=mysecretpassword -p 25432:5432 --name osm-database osm-database 

,并使用来自另一个容器(OSM-更新)泊坞窗链接连接到它

docker run -d --link osm-database --name osm-updater osm-updater 

现在我发现我不能psql的来自OSM-更新容器数据库,得到错误

psql: could not connect to server: Connection refused 
Is the server running on host "172.17.0.12" and accepting 
TCP/IP connections on port 5432? 

所以探索了OSM-数据库容器内的网络套接字与

netstat -tulpn 

结果

tcp  0  0 127.0.0.1:5432   0.0.0.0:*    LISTEN 

其示出了OSM-数据库容器内,以postgres分贝可以只能连接到127.0.0.1这是错误的?应该是0.0.0.0:5432?

让我无法从OSM-更新命令状

psql -U postgres -p 5432 -h 172.17.0.12 

172.17.0.12连接到OSM数据库是(搬运工检查命令)

获得IP_ADDRESS我怎么能解决这个问题?如何更改网络插槽的“本地地址”列

回答

0

您实际上想要使用机器的eth0。如果你在Linux中,你可以通过ifconfig来获取它,并且连接到端口25432上的数据库,因为这是你正在展示的端口。

相关问题