1

The latest release of Docker doesn't use a virtual machine anymore, instead using a hypervisor to connect to the containers. This means I can no longer login to postgres with psql:

➜  postgres git:(master) ✗ docker run -d -p 5433:5432 db postgres
<sha>
➜  postgres git:(master) ✗ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
111f3bed4c52        db                  "/docker-entrypoint.s"   17 minutes ago      Up 17 minutes       0.0.0.0:5433->5432/tcp   zen_hugle
➜  postgres git:(master) ✗ psql -p 5433 -U postgres
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5433"?

I have also tried specifying localhost as the host, but that results in a strange output:

➜  postgres git:(master) ✗ psql -h localhost -p 5433 -U postgres
psql: %

Does anyone know what to do in this case? Thank you.

  • 1
    That second case looks like you are connected. Is something not working with that? – JoshRagem Aug 9 '16 at 12:54
  • 1
    I'm not sure it's the problem of Docker. Can you connect if you add -h localhost to the psql command? – dezso Aug 9 '16 at 13:40
  • Sorry about the delay in responding. Yes, I can connect to the local postgres database at the port 5432. But I cannot connect to the one at 5433, which is in the docker container. – picardo Aug 14 '16 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.