Glxinfo displays nvidia vendor on host, but not in container

I’m trying to set it up so that GUI apps run in a container would use the nvidia GPU by default, or at least would use it with the right env variables added (for example when using prime-run).

I’m trying to verify the behavior via glxinfo. If I run glxinfo on the host with these env variables it shows nvidia as the vendor:

$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep vendor
server glx vendor string: NVIDIA Corporation
client glx vendor string: NVIDIA Corporation
OpenGL vendor string: NVIDIA Corporation

however if I run a container via:

rocker --nvidia --x11 --user -- nvidia/cuda:11.0.3-base-ubuntu20.04 /bin/bash

(rocker is a similar tool to docker-compose that makes it easier to use nvidia drivers and x11, but please let me know what the equivalent docker command would be)

Running glxinfo inside the container shows intel rather than nvidia:

$  __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep vendor
libGL error: MESA-LOADER: failed to retrieve device information
server glx vendor string: SGI
client glx vendor string: Mesa Project and SGI
OpenGL vendor string: Intel Open Source Technology Center

FWIW, nvidia-smi appears to work fine inside the container:

$ nvidia-smi
Tue Oct 25 23:11:41 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.73.05    Driver Version: 510.73.05    CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
... etc ..

nvidia-bug-report.log.gz (390.5 KB) - collected from the host

I do have simillar issue
I got error in container : Error, could not find RGB GLX visual or fbconfig