NVIDIA Driver was not detected inside docker container

Setup: Ubuntu 24/22

docker: Docker version 29.0.0, build 3d4129b

nvidia-toolkit-container: 1.18.0/1.17.1

Have already tried : troubleshoot

command: docker run --runtime nvidia --gpus all -it nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04 bash
result: WARNING: The NVIDIA Driver was not detected. GPU functionality will not be available.

Its happening accross systems with ubuntu 22/24, and with above software versions, have tried quite a few solutions, any help would be appreciated.

with new nvidia-container-runtimes

inside /etc/nvidia-container-runtime/config.toml following flag is disabled,

accept-nvidia-visible-devices-envvar-when-unprivileged = false

enabling it or commenting it should work

or use this solution Docker forum