I seem to be hitting some sort of permissions issue while trying to use unix sockets between my host and a Docker container.
Within a running container, I have a server listening to a unix socket on a mounted volume. When I attempt to connect to the socket from outside the container (using the mounted volume), I get an ECONNREFUSED error. I have verified that what I am talking to is a socket created by the container.
I'm assuming there must be something very basic I am missing here that is preventing this from working.
Some additional information:
- Container running Linux (have also tried ubuntu)
- I am running Mac OS, however my co-worker has the same issue on Linux
- The file seems to have different owners between Docker and my Host (owned by root and my current user, respectively), however both have the
srwxrwxrwxpermissions. - The volume's directory on my host machine is set in my
Resources > File Sharingsettings in Docker Desktop - Our Docker Compose file has given explicitly read-write permissions to the volume.
- If I call the socket from within the container, it works as expected.
I've read pretty much the entire reference for volumes in Docker Compose, I've read pretty much every tutorial and Stack Overflow post on the topic, and it still seems to persist.
Any ideas on why this might not be working would be greatly appreciated!
There might be different reasons, but most probably:
Check if you use host networking mode for your Docker container
Disable SELinux or AppArmor modules in Linux or configure them to allow the socket communication.
you can check if SELinux is blocking socket communications
/var/log/audit/audit.log, if it is blocking, create custom policy module to allow it.Also, While the socket permission is srwxrwxrwx, but You could try to change the owner of the socket file or add your user to the docker group
Hope that help!