User inside Docker container can't access X11 (but root can) on a Ubuntu 22.04 with Wayland

Hi all,
I am running Ubuntu 22.04 with Wayland and having trouble starting a Docker (Version: 20.10.22, build 3a2c30b) container as a specific user (ubuntu) that is created in the DOCKERFILE and in the entrypoint I use exec gosu ubuntu "$@".
I installed docker and ran the “”.

My problem is, that only the root user inside the docker container can start X11 applications, and when I try to chown the folder specified in the variable X11 Socket in the container I get the error: “chmod: changing permissions of ‘/tmp/.X11-unix’: Operation not permittet”, the permissions of ‘/tmp/.X11-unix’ are as follows inside the container: drwxrwxrwt 2 nobody nogroup 4.0K Jan 5 06:35 .X11-unix
On the host I created a group with the UID (100999) and GUID (100999) of the user in the docker container and used sudo setfacl -R -m "g:docker_share:rx" /tmp/.X11-unix/ to add read and execute permissions to the X11 Socket for the group.

This is the Dockerfile:

FROM osrf/ros:humble-desktop-full
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update && apt-get install -y --no-install-recommends \
    tmux xterm gosu \
    python3-pip python3-vcstool python3-rosdep \
    ros-humble-turtlebot3* && \
    apt-get clean &&  rm -rf /var/lib/apt/lists/*

RUN addgroup --gid $GROUP_ID ubuntu && \
    adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID ${USERNAME} && \
    usermod -g sudo ${USERNAME} && passwd -d ${USERNAME}
# Fix for: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
RUN su ${USERNAME} -c "pip install setuptools==58.2.0"
RUN su ${USERNAME} -c "rosdep update"

COPY --chown=${USER_ID}:${GROUP_ID} bug_planning/dependencies.yml /home/${USERNAME}/ros2_ws/src/dependencies.yml 
WORKDIR /home/${USERNAME}/ros2_ws/
# RUN vcs import src < src/dependencies.yml && sudo apt-get update && \
#     rosdep install --from-paths src --ignore-src -r -y && /bin/bash -c ". /opt/ros/humble/setup.bash; colcon build --symlink-install" && \
#     sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*

RUN echo "set -g mouse on" > /home/${USERNAME}/.tmux.conf
RUN chmod +x /

This is the “/” script that is used as the ENTRYPOINT int docker:

set -e

# Ensure host and container have the same user ID. This is to allow both sides
# to read and write the shared directories.
if [ -v USER_ID ] && [ "$USER_ID" != "$DEFAULT_USER_ID" ]; then
    echo "Changing ubuntu user ID to match your host's user ID ($USER_ID)." 
    echo "This operation can take a while..."

    usermod --uid "$USER_ID" ubuntu

    # Ensure all files in the home directory are owned by the new user ID
    find /home/ubuntu -user $DEFAULT_USER_ID -exec chown -h "$USER_ID" {} \;
# If no command is provided, set bash to start interactive shell
if [ -z "$1" ]; then
    set - "/bin/bash" -l

# setup ros2 environment
source "/opt/ros/$ROS_DISTRO/setup.bash" --
if [ -f "/home/ubuntu"/ros2_ws/install/setup.bash ]; then
    source "/home/ubuntu/ros2_ws/install/setup.bash" --
exec gosu ubuntu "$@"

And I try to start it using the following script:

set -e 


xhost +
docker run -it --rm \
    --name="bug_path_planning" \
    --mount type=bind,source="$XSOCK",target="$XSOCK" \
    --mount type=bind,source="$XAUTH",target="$XAUTH" \
    --env="DISPLAY=${DISPLAY}" \
    --env="XSOCK=${XSOCK}" \
    --env="XAUTH=${XAUTH}" \
    --shm-size=1g \
    --env="QT_X11_NO_MITSHM=1" \
    --mount type=bind,source="$HOST_DIR",target="$DOCKER_DIR" \
    bug:$(git rev-parse --abbrev-ref HEAD) tmux
xhost -

The code works if I switch from Wayland to Xorg.
For this I edited in /etc/gdm3/custom.conf the line WaylandEnable=true to WaylandEnable=false
Any Idea how to make it also work with Wayland?