Unable to use Nvidia opengl driver inside a docker container

I have setup my docker file to use base as nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04. I am using a vnc server on top of that.

When I try to run a my qt5 based gui application, it says “Open GL 4.2 not supported”.

The output of glxinfo | grep -i “version”:

server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
    Version: 18.2.8
    Max core profile version: 3.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL version string: 3.1 Mesa 18.2.8
OpenGL shading language version string: 1.40

For some reason, its not using the nvidia display driver. Output of nvidia-smi:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.48                 Driver Version: 410.48                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           Off  | 00000000:00:04.0 Off |                    0 |
| N/A   35C    P0    68W / 149W |      0MiB / 11441MiB |    100%      Default |
+-------------------------------+----------------------+----------------------+

Can anyone help me figure out the reason?

The vnc server is a virtual Xserver that is using software rendering. If you want it to use the real Xserver running on the nvidia gpu, try this:
http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/