I want to connect to a unix domain socket on the host from within a docker container. Specifically, I run this on the host:
socat - ABSTRACT-LISTEN:/tmp/.X11-unix/X1
And run this in the container:
socat ABSTRACT-CONNECT:/tmp/.X11-unix/X1 -
The expected result is bidirectional communication. But this is met only when the container is run with --net=host:
docker run -it --net=host ubuntu bash
Omitting --net=host gives me ECONNREFUSED (Connection refused):
docker run -it ubuntu bash
Question: Why does --net matter for a unix domain socket connection?
Question: Is it best practice to use --net=host only for allowing unix domain socket connection?