1

This is seemingly the same as this issue, though I thought I'd provide a simple example:

docker run -it \
  -v /pg_socket_on_host:/pg_socket_in_container \
  -e PGPASSWORD=${PGPASSWORD} \
  postgres \
  psql -h /pg_socket_in_container -U postgres postgres

Where the path /pg_socket_on_host is a directory containing the file .s.PGSQL.5432. I've tried a few different versions of this, but I keep ending up with the same result:

psql: error: connection to server on socket "/pg_socket_in_container/.s.PGSQL.5432" failed: Connection refused
    Is the server running locally and accepting connections on that socket?

Is there a reason that this is a problem with Docker?

Follow up:

I ensured that the permissions and the user (name and id, as well as group and id) for the host and container path/volume line up based on this post, but I still get the same error. I am able to connect to the socket on the host machine from the host machine. I am also able to connect to the host via host.docker.internal from the docker container. Any other ideas about debugging strategies?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.