How to launch Nsight Compute/System GUI in a container

I want to profile my CUDA kernels in a docker container.
It is okay if I do it with non-gui version of nsight compute and system.
But if I want to use GUI, they can not be launched.

This is my Dockerfile:

FROM nvcr.io/nvidia/l4t-cuda:12.2.12-runtime

# Install nvidia-l4t-core
RUN \
    echo "deb https://repo.download.nvidia.com/jetson/common r36.3 main" >> /etc/apt/sources.list && \
    echo "deb https://repo.download.nvidia.com/jetson/t234 r36.3 main" >> /etc/apt/sources.list && \
    apt-key adv --fetch-key http://repo.download.nvidia.com/jetson/jetson-ota-public.asc && \
    mkdir -p /opt/nvidia/l4t-packages/ && \
    touch /opt/nvidia/l4t-packages/.nv-l4t-disable-boot-fw-update-in-preinstall

RUN apt-get update \
    && echo "Y" | apt-get install -y --no-install-recommends nvidia-l4t-core

ENV UDEV=1

# Install CUDA driver 12.4
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/arm64/cuda-keyring_1.1-1_all.deb \
  && dpkg -i cuda-keyring_1.1-1_all.deb \
  && apt-get update \
  && apt-get -y install cuda-toolkit-12-4 cuda-compat-12-4

# Install necessary dependencies including gcc
RUN apt-get update \
    && apt-get install -y wget gdb build-essential git cmake libzmq3-dev pkg-config curl vim python3 python3-pip docker-compose ninja-build \
    && rm -rf /var/lib/apt/lists/*

# Install jtop 
RUN pip3 install jetson-stats

WORKDIR /

# Install GCC 12 and G++ 12
RUN apt-get update \
    && apt-get install -y software-properties-common \
    && add-apt-repository ppa:ubuntu-toolchain-r/test \
    && apt-get update \
    && apt-get install -y gcc-12 g++-12 \
    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 \
    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100

# Nsight
RUN apt update \
  && apt install -y nsight-compute-2024.3.2 \
  && apt install -y nsight-systems-2024.2.2

# QT6
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
        qt6-base-dev && \
    apt-get clean

RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        dbus \
        fontconfig \
        gnupg \
        libasound2 \
        libfreetype6 \
        libglib2.0-0 \
        libnss3 \
        libsqlite3-0 \
        libx11-xcb1 \
        libxcb-glx0 \
        libxcb-xkb1 \
        libxcomposite1 \
        libxcursor1 \
        libxdamage1 \
        libxi6 \
        libxml2 \
        libxrandr2 \
        libxrender1 \
        libxtst6 \
        libgl1-mesa-glx \
        libxkbfile-dev \
        openssh-client \
        wget \
        xcb \
        xkb-data && \
    apt-get clean

# Add lines to ~/.bashrc
RUN echo 'export PATH=/usr/local/cuda-12.4/bin:$PATH' >> ~/.bashrc \
  && echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.4/compat:$LD_LIBRARY_PATH' >> ~/.bashrc

You can see that I already setup Qt6 and the necessary libs for displaying GUI.
Please help me revise the Dockerfile, thanks!

==========
== CUDA ==

CUDA Version 12.2.12

Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license

A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.

root@a4c13bfba5b3:/# ncu-ui
Detected locale “C” with character encoding “ANSI_X3.4-1968”, which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to “C.UTF-8” instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.
qt.qpa.xcb: could not connect to display localhost:10.0
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, wayland, wayland-egl.

Application could not be initialized!
This is likely due to missing Qt platform dependencies.
For a list of dependencies, please refer to Qt for X11 Requirements | Qt 6.8
To view missing libraries, set QT_DEBUG_PLUGINS=1 and re-run the application.

Warning: OpenGL Version check failed. Falling back to Mesa software rendering.
Detected locale “C” with character encoding “ANSI_X3.4-1968”, which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to “C.UTF-8” instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.
qt.qpa.xcb: could not connect to display localhost:10.0
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, wayland, wayland-egl.

################# ERROR: CrashReporter #################
CrashReporter

Qt initialization failed

Failed to load Qt platform plugin: “xcb”

  • Library path: /opt/nvidia/nsight-compute/2024.3.2/host/linux-v4l_l4t-t210-a64/Plugins/platforms/libqxcb.so
    Application is going to abort
    sh: 1: xmessage: not found
    Aborted (core dumped)

I have reproduced this. So would appreciate some help.