I can't connect my Postgres container with my golang webapp container.
i got following error:
panic: dial tcp [::1]:5432: getsockopt: connection refused
My docker compose file:
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:
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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.