I have a service running in Docker that listens on a Unix Domain Socket, and a client running on the Docker host (a Mac). The client gets a "Connection Refused" error trying to connect.

I'm mapping the volume when I run the server (docker run -it -v /localpath:/var/run myservice) and I see the socket file created in the local dir just fine.

It works fine if I also run the client in Docker (different container instance), or if I run both locally. But if I run one side in Docker and the other locally it fails (I've tried both directions). I thought it might be a uid/gid mismatch but that looks ok, and if I force them to be different I get a permission denied error.

My app is using Java 16's UnixDomainSocketAddress, but I've also tested with a python script (using an AF_UNIX socket) and see the same problem, so it seems like a Docker thing. Any ideas?

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.