I am trying to run Xvfb within a Docker container, but it is failing with the error:
$ Xvfb :0 -nolisten tcp -screen 0 1024x768x24
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
According to strace, it's trying to bind a UNIX socket at /tmp/.X11-unix/X0
:
bind(4, {sa_family=AF_UNIX, sun_path=@"/tmp/.X11-unix/X0"}, 20) = -1 EADDRINUSE (Address already in use)
However, the file does not already exist in the container (verified by ls -l /tmp/.X11-unix
).
If I use a different screen number, like :1
, the program succeeds.
This container is running in --network host
mode, and /tmp/.X11-unix/X0
does exist on the host. Does this create some kind of issue where the container and the host cannot have a UNIX socket at the same path, even if that socket is not visible in the container?