This will fail at first and look something like this, but that's ok: volume='/tmp/.X11-unix:/tmp/.X11-unix:rw' \Ībove, we made the container's processes interactive, forwarded our DISPLAY environment variable, mounted a volume for the X11 unix socket, and recorded the container's ID. The simple way is expose your xhost so that container can render to the correct display by reading and writing though the X11 unix socket.
The first listed is simple, but unsecure.A brief description and tradeoffs for each method below: There are several ways one can connect a container to a host's X server for display. X server is a windowing system for bitmap displays, common on linux operating systems. And it can also pass through PulseAudio with -pulse. It can also pass through your user using -user and mount your home directory using -home. If you have an nvidia driver and need graphics acceleration you can run it with -x11 as an option to enable the X server in the container. Rocker is a tools which will help you run docker containers with hardware acceleration.