Docker Community Forums

Share and learn in the Docker community.

`glxgears` launching failure withing docker container

I have the following Dockerfile:

FROM centos:7.5.1804

RUN yum -y install glx-utils
ENV LIBGL_DEBUG "verbose glxgears"

Then, I build an image:

docker build -t glx .

##1
When I try to run the image:

docker run --rm -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ --privileged glx glxgears

I get the following error:

libGL: screen 0 does not appear to be DRI2 capable
libGL: OpenDriver: trying /usr/lib64/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib64/dri/swrast_dri.so
libGL: dlopen /usr/lib64/dri/swrast_dri.so failed (/usr/lib64/dri/swrast_dri.so: cannot open shared object file: No such file or directory)
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Error: couldn't get an RGB, Double-buffered visual

##2
However, if I try to install glx-utils and run glxgears directly, I don’t get any error:

docker run --rm -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ --privileged centos:7.5.1804 yum -y install glx-utils && glxgears

Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
300 frames in 5.0 seconds = 59.953 FPS
300 frames in 5.0 seconds = 59.971 FPS

##3
Also, if I mount my whole /usr/lib64, I don’t get any error either:

docker run --rm -ti -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /usr/lib64:/usr/hostLib64 --privileged centos:7.5.1804

(inside container)

export LD_LIBRARY_PATH=/usr/hostLib64
yum -y install glx-utils
glxgears # runs smoothly.

From ##3, I have convinced myself that I am missing some libraries. Can anyone help in this regard?

I have tried starting from nvidia/opengl:1.1-glvnd-runtime-centos7 image instead of centos:7.5.1804, ##1 and ##2 are still observed.

Similar issue is reported here: https://github.com/sylabs/singularity/issues/4290 and here: https://github.com/NVIDIA/nvidia-docker/issues/136#issuecomment-232755805. But none of them has been promising for me.