2

When I run docker run -it --net=host -e DISPLAY=$DISPLAY <image> and xhost + on my host device, the gui applications in the docker container works well. However, when it comes to rootless dockerd (with env DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock when using docker cli), the gui applications do not work and prompts

Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0

So what is the difference between root and rootless docker container when connecting to the host display and how to use gui in rootless docker containers?

1 Answer 1

2

In rootless Docker, the host machine cannot be reached even if you use --net=host.

Rootless Mode Known limitations:

Host network (docker run --net=host) is also namespaced inside RootlessKit.

You can display with sharing XServer socket.

docker run -it --volume=/tmp/.X11-unix/:/tmp/.X11-unix/ -e DISPLAY=$DISPLAY <image>

There is no need to xhost +, because the UID in the rootless container is mapped to the docker execution user on the host.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .