Dorokhov.codes
06. Run GUI apps inside containers
X11
X11 works on a client-server model, where the X server runs on the local machine, and applications act as clients that send requests to the server to create windows, draw graphics, handle user input, and perform other GUI-related tasks. The server manages the display hardware and communicates with the clients using the X protocol.
We are going to use X11 as a shared component between the host system and the docker container.
We should provide access for the clients. There are several different ways for X11 applications to authenticate themselves to the server.
# Allow any local application to access the display server:
xhost +local:*
# Disable it:
xhost -local:*
Or by providing the cookies to the clients:
# We should take cookies from the host:
xauth list
# And provide it to the client:
xauth add :0 COOKIE_NAME 3956c715c6149d01cb1b60e5790f49b7
Start a container
docker container run -it --net=host -e DISPLAY -v /tmp/.X11-unix <image-name> bash