0

I'm quite new to the docker images, containers and all the logic behind linking the running containers together, so please be patient if this question sounds too stupid.

I'm trying to setup a working DB (PostgreSQL) server on Google Container Engine service and connect to it from other docker images running on same cluster.

I have setup a google cloud project, enabled cloud container API, created container cluster and ran postgres official Docker images postgres:latest. So far so good.

And here comes the issue: When I attach a root bash console to the running instance, I can connect via psql command without a problem.

But when I try to connect to it from different machine (even after enabling external access to the service and letting it through the firewall (ping command works from my local machine), every access fails with this error message:

psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

I'm connecting via classic:

psql -h xxx.xxx.xxx.xxx -U myuser -W -d somedatabase

Does someone has an idea why this won't work?

koressak
  • 176
  • 5
  • This also applies for the docker mysql official image, so this kind of reminds me that it cannot be issue of the image itself. – koressak Aug 13 '15 at 13:38
  • It could be lots of things. If it works on the machine (`-h localhost`) but not outside that machine, then it's obviously some sort of security problem. Perhaps not all the ports are open on your destination machine, or you have an overactive firewall, a defective NAT, or you have the google equivalent of amazon's "security groups" in place that aren't configured properly. I'm unfamiliar with docker and google's container engine, but I'd recommend looking into the documentation for any security features that are in place on your target machine. – Jacklynn Aug 13 '15 at 15:39
  • Are there errors in the logs for postgresql? When you connect via localhost, what is the output of `SELECT * FROM version()`? What is the output of `psql -V` on your remote server? – Kassandry Sep 05 '15 at 07:04

1 Answers1

0

Thanks for the replies, but finally I found the solution.

Maybe this will help somenone who starts experimenting with the Docker on Google Container Engine.

The issue here is to properly configure port numbers and their respective names in the pod definition. Without the name, the port won't work (at least it seemed that way). As soon as I added a port name, the connection worked like a charm.

koressak
  • 176
  • 5