Ubuntu – Start GUI-Application in Docker Container with sudo


System: Ubuntu 16.04
Display-Manager: lightdm

I'm trying to create a docker container FROM ubuntu:latest where a GUI-Application is running in.
The application needs to get executed with sudo to access the inside used commands.
I followed the instruction of this Blog and adapted it for my use.

After i build this container I first ran it with:

docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix repo-test-3 /bin/bash



and the application is shown at the screen.

The next I tried to run the same container with -u 0 to become root and after i tried to start the application the following error message appears:

No protocol specified
QXcbConnection: Could not connect to display :0
Aborted (core dumped)

Do you have any idea whats the problem and how I can fix this?

Best Answer

The solution is:

Give docker the rights to access the X-Server with:

xhost +local:docker
Related Question