2

This is a question about Docker networking and running an OpenGL GUI application within a docker container.

This example shows that to get this particular OpenGL example to run in a Docker container that the --net=host option must be provided. Certainly, the example doesn't work correctly without that option.

My question is, if I don't want to specify --net=host because I want it to be part of a different network, then is there a way to specify some other options when creating the container that will cherry-pick the exact network changes or port mappings required to get it to run?

I don't fully understand why it needs the --net=host option. (I think it has something to do with the X11 server??) Previously (before my container was using OpenGL) there was a mynetwork network that my container was using to speak to other docker containers on the system. And so it was being launched with --net=mynetwork. But now, specifying --net=host instead, gets the new OpenGL features working, but breaks the features that required communication with the other docker containers on the mynetwork network.

I seek to better understand why OpenGL requires --net=host and if there's something else I can do besides --net=host to correctly enable whatever the container actually needs with respect to host networking so that I can both 1) communicate with my other containers on the mynetwork network, and 2) use the OpenGL features.

Maybe there's a way involving setting DISPLAY and/or XAUTHORITY to some values that will let the container connect to the host correctly? Possibly there's an additional step involved on the host to permit this (beyond just xhost +)?

For completeness, here is the aforementioned example (intended to be run on an NVIDIA Jetson Nano). Seeking an alternative to --net=host is the relevant part of my question.

$ xhost +
$ sudo docker run -it --rm --net=host --runtime nvidia -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix nvcr.io/nvidia/l4t-base:r32.3.1
$ apt-get update && apt-get install -y --no-install-recommends make g++
$ /usr/local/cuda-10.0/bin/cuda-install-samples-10.0.sh /tmp
$ cd /tmp/NVIDIA_CUDA-10.0_Samples/2_Graphics/simpleGL
$ make
$ ./simpleGL
Wyck
  • 10,311
  • 6
  • 39
  • 60
  • I don't know the answer to this but I think it has something to do with IndirectGLX. I don't really understand why the nvidia examples have you mount in the `/tmp/.X11-unix/` either when it's not even needed if you use `--net host`. Anyways I tried for a while to see if I could get IndirectGLX to make it work but I didn't have any luck. – Shannon Poole Apr 21 '21 at 02:43

0 Answers0