The core is to use the local display, adding some configuration before launching the Docker Image
- Install the dependencies on the machine first (only need to be executed once, subsequent commands need to be executed every time a DOCker that requires a GUI is started)
sudo apt-get install x11-xserver-utils
Copy the code
- Open access
xhost +
Copy the code
- Add docker parameter options
-v /tmp/.X11-unix:/tmp/.X11-unix \
: Shares the local Unix port-e DISPLAY=unix$DISPLAY \
: Modifies the environment variable DISPLAY-e GDK_SCALE
-e GDK_DPI_SCALE
The command to finally start the testName :v0 mirror is:
xhost +
sudo docker run -it \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
testname:v0 \
/bin/bash
Copy the code
After starting some drawing or GUI Windows in the container, you can use the display screen to display the window