[英]Docker: connection between golang webapp and postgres server refused
I can't connect my Postgres container with my golang webapp container. 我无法将我的Postgres容器与golang webapp容器连接。
i got following error: 我得到以下错误:
panic: dial tcp [::1]:5432: getsockopt: connection refused
My docker compose file: 我的码头组成文件:
http://pastebin.com/5LQfn3gy http://pastebin.com/5LQfn3gy
Any idea how i can fix that? 知道如何解决这个问题吗?
Since the IP you specified relates to your host and not your docker environment and you're running your app inside docker too, just omit the IP: 由于您指定的IP与您的主机有关,而与您的docker环境无关,并且您也在docker中运行您的应用程序,只需省略IP:
ports:
-5432:5432
So you'd just need to pass the Postgres alias, followed by its port to your go app (either as an env var or a flag). 因此,您只需要传递Postgres别名,然后将其端口传递给您的应用程序(作为env var或标志)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.