############################################### base on allision https://github.com/athackst/dockerfiles/blob/main/ros2/humble.Dockerfile########################################################################################## Base image###########################################FROMubuntu:22.04ASbaseENVDEBIAN_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/*
RUNapt-getupdate&&apt-get-yupgrade\&&rm-rf/var/lib/apt/lists/*
# Install common programsRUNapt-getupdate&&apt-getinstall-y--no-install-recommends\curl\gnupg2\lsb-release\sudo\software-properties-common\wget\&&rm-rf/var/lib/apt/lists/*
# Install ROS2RUNsudoadd-apt-repositoryuniverse\&&curl-sSLhttps://raw.githubusercontent.com/ros/rosdistro/master/ros.key-o/usr/share/keyrings/ros-archive-keyring.gpg\&&echo"deb [arch=$(dpkg--print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(./etc/os-release&&echo$UBUNTU_CODENAME) main"|sudotee/etc/apt/sources.list.d/ros2.list>/dev/null\&&apt-getupdate&&apt-getinstall-y--no-install-recommends\ros-humble-ros-base\python3-argcomplete\&&rm-rf/var/lib/apt/lists/*
ENVROS_DISTRO=humble
ENVAMENT_PREFIX_PATH=/opt/ros/humble
ENVCOLCON_PREFIX_PATH=/opt/ros/humble
ENVLD_LIBRARY_PATH=/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib
ENVPATH=/opt/ros/humble/bin:$PATHENVPYTHONPATH=/opt/ros/humble/local/lib/python3.10/dist-packages:/opt/ros/humble/lib/python3.10/site-packages
ENVROS_PYTHON_VERSION=3ENVROS_VERSION=2ENVROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET
ENVDEBIAN_FRONTEND=############################################ Develop image###########################################FROMbaseASdevENVDEBIAN_FRONTEND=noninteractive
RUNapt-getupdate&&apt-getinstall-y--no-install-recommends\bash-completion\build-essential\cmake\gdb\git\openssh-client\python3-argcomplete\python3-pip\python-is-python3\tmux\tmuxp\vim\&&rm-rf/var/lib/apt/lists/*
RUNrosdepinit||echo"rosdep already initialized"ARGUSERNAME=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/*
ENVAMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1# Install the full releaseRUNapt-getupdate&&apt-getinstall-y--no-install-recommends\ros-humble-ros-base\ros-humble-rmw-cyclonedds-cpp\ros-dev-tools\python3-colcon-clean\ros-humble-ament-*\&&rm-rf/var/lib/apt/lists/*
ENVDEBIAN_FRONTEND=# Set up autocompletion for userRUNapt-getupdate&&apt-getinstall-y--no-install-recommendsgit-corebash-completion\&&echo"if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi">>/home/$USERNAME/.bashrc\&&echo"if [ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ]; then source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash; fi">>/home/$USERNAME/.bashrc\&&rm-rf/var/lib/apt/lists/*
COPY.tmux.conf/etc/tmux.conf
############################################### base on allision https://github.com/athackst/dockerfiles/blob/main/ros2/jazzy-cuda.Dockerfile########################################################################################## Base image ver 0.1###########################################FROMnvidia/cuda:12.6.2-cudnn-runtime-ubuntu24.04ASbaseENVDEBIAN_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/*
RUNapt-getupdate&&apt-get-yupgrade\&&rm-rf/var/lib/apt/lists/*
# Install common programsRUNapt-getupdate&&apt-getinstall-y--no-install-recommends\curl\gnupg2\lsb-release\sudo\software-properties-common\wget\&&rm-rf/var/lib/apt/lists/*
# Install ROS2RUNsudoadd-apt-repositoryuniverse\&&curl-sSLhttps://raw.githubusercontent.com/ros/rosdistro/master/ros.key-o/usr/share/keyrings/ros-archive-keyring.gpg\&&echo"deb [arch=$(dpkg--print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(./etc/os-release&&echo$UBUNTU_CODENAME) main"|sudotee/etc/apt/sources.list.d/ros2.list>/dev/null\&&apt-getupdate&&apt-getinstall-y--no-install-recommends\ros-jazzy-ros-base\python3-argcomplete\&&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=1ENVROS_DISTRO=jazzy
ENVAMENT_PREFIX_PATH=/opt/ros/jazzy
ENVCOLCON_PREFIX_PATH=/opt/ros/jazzy
ENVLD_LIBRARY_PATH=/opt/ros/jazzy/lib/x86_64-linux-gnu:/opt/ros/jazzy/lib
ENVPATH=/opt/ros/jazzy/bin:$PATHENVPYTHONPATH=/opt/ros/jazzy/local/lib/python3.12/dist-packages:/opt/ros/jazzy/lib/python3.12/site-packages
ENVROS_PYTHON_VERSION=3ENVROS_VERSION=2ENVROS_AUTOMATIC_DISCOVERY_RANGE=SUBNET
RUNapt-getupdate&&apt-getinstall-y--no-install-recommends\bash-completion\build-essential\cmake\gdb\git\openssh-client\python3-argcomplete\python3-pip\ros-dev-tools\python3-colcon-clean\ros-jazzy-ament-*\vim\ros-jazzy-rmw-cyclonedds-cpp\ros-jazzy-ros-gz-bridge\ros-jazzy-ros-gz-image\&&rm-rf/var/lib/apt/lists/*
RUNrosdepinit||echo"rosdep already initialized"ARGUSERNAME=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/*
# Set up autocompletion for userRUNapt-getupdate&&apt-getinstall-y--no-install-recommendsgit-corebash-completion\&&echo"if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi">>/home/$USERNAME/.bashrc\&&echo"if [ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ]; then source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash; fi">>/home/$USERNAME/.bashrc\&&rm-rf/var/lib/apt/lists/*
ENVDEBIAN_FRONTEND=ENVAMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1COPY.tmux.conf/etc/tmux.conf
cuda version
Check host cuda version using nvidia-smi , I encountered problems if the docker image cuda version was higher