# my current cuda version is 12.4dockerpullnvidia/cuda:12.4.0-runtime-ubuntu22.04
dockerrun--gpsall-it--rmnvidia/cuda:12.4.0-runtime-ubuntu22.04/bin/bash
# from docker nvida-smi
FROMnvidia/cuda:12.4.0-runtime-ubuntu22.04ASbase# Avoid warnings by switching to noninteractiveENVDEBIAN_FRONTEND=noninteractive
# Install languageRUNapt-getupdate&&apt-getinstall-y--no-install-recommends\locales\&&locale-genen_US.UTF-8\&&update-localeLC_ALL=en_US.UTF-8LANG=en_US.UTF-8\&&rm-rf/var/lib/apt/lists/*
ENVLANG=en_US.UTF-8
# Install timezoneRUNln-fs/usr/share/zoneinfo/UTC/etc/localtime\&&exportDEBIAN_FRONTEND=noninteractive\&&apt-getupdate\&&apt-getinstall-y--no-install-recommendstzdata\&&dpkg-reconfigure--frontendnoninteractivetzdata\&&rm-rf/var/lib/apt/lists/*
# install packagesRUNapt-getupdate&&apt-getinstall-q-y\curl\gnupg\lsb-release\python3-argcomplete\sudo\wget\&&wgethttps://packages.osrfoundation.org/gazebo.gpg-O/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg\&&echo"deb [arch=$(dpkg--print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release-cs) main"|tee/etc/apt/sources.list.d/gazebo-stable.list>/dev/null\&&apt-getupdate&&apt-getinstall-y-q\gz-harmonic\&&rm-rf/var/lib/apt/lists/*
################# Expose the nvidia driver to allow opengl# Dependencies for glvnd and X11.################RUNapt-getupdate\&&apt-getinstall-y-qq--no-install-recommends\libglvnd0\libgl1\libglx0\libegl1\libxext6\libx11-6
# Env vars for the nvidia-container-runtime.ENVNVIDIA_VISIBLE_DEVICES=all
ENVNVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute
ENVQT_X11_NO_MITSHM=1ARGUSERNAME=user
ARGUSER_UID=1000ARGUSER_GID=$USER_UID# Check if "ubuntu" user exists, delete it if it does, then create the desired userRUNifgetentpasswdubuntu>/dev/null2>&1;then\userdel-rubuntu&&\echo"Deleted existing ubuntu user";\fi&&\groupadd--gid$USER_GID$USERNAME&&\useradd-s/bin/bash--uid$USER_UID--gid$USER_GID-m$USERNAME&&\echo"Created new user $USERNAME"# Add sudo support for the non-root userRUNapt-getupdate&&apt-getinstall-ysudo\&&echo$USERNAMEALL=\(root\)NOPASSWD:ALL>/etc/sudoers.d/$USERNAME\&&chmod0440/etc/sudoers.d/$USERNAME\&&rm-rf/var/lib/apt/lists/*
CMD["bash"]
Docker environment variables
QT_X11_NO_MITSHM=1 is used to disable the MIT-SHM extension for X11, which can cause issues with some applications running in Docker containers.
NVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute is used to specify the capabilities of the NVIDIA driver that should be exposed to the container. This is important for GPU-accelerated applications.
NVIDIA_VISIBLE_DEVICES=all is used to make all NVIDIA GPUs visible to the container. This is important for GPU-accelerated applications that need access to the GPU.
gz_transport is Gazebo's communication middleware, used for inter-process communication (IPC) between different Gazebo components — like sensors, plugins, UI, and even ROS bridges.
GZ_PARTITION: Isolates topic namespaces between different simulations
GZ_DISCOVERY_SERVER: IP address of the main discovery server (usually the Gazebo server machine)
GZ_TRANSPORT_IP: IP address the local process uses to advertise itself to others