PyQt6 cannot start the application

I am trying to dockerize my PyQt6 application and I do have some problems with it.

My application works fine outside the docker. I wrote my Dockerfile:

FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
    python3.10 \
    python3-pip \
    libgl1-mesa-glx \
    libegl1-mesa \
    libqt6core6 \
    libqt6gui6 \
    libqt6widgets6 \
    && rm -rf /var/lib/apt/lists/*

COPY pyproject.toml poetry.lock /draughts/

RUN pip install poetry

RUN cd /draughts && \
    poetry config true && \ poetry install --without=dev

COPY . /draughts

To run the image I use this command: sudo docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY draughts

So after connecting to the container I cd to my applicatoin and run poetry run python src/draughts/
The output from this command is:

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, vkkhrdisplay, offscreen, eglfs, vnc, wayland-egl, wayland, minimalegl, linuxfb, minimal.

Aborted (core dumped)

Am I missing some steps or packages here?

You may be missing the following environment variables:

I’m not sure the last one is meant to be written. (maybe read only)

This mounts a folder containing a unix domain socket and that can’t be mounted into a virtual machine which is run by Docker Desktop.