Execute graphical applications from Docker

Hello Clear Linux users.
I’m running clear linux and I am unable to start a simple docker graphical application (xclock) like

https://hub.docker.com/r/sshipway/xclock/

Neither GNOME on Wayland nor GNOME on X work, the command I use is

giacomo@woody ~ $ echo $DISPLAY 
:0

xhost +

docker run --rm -it  -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix    sshipway/xclock

I get:
Error: Can't open display: :0

So, my question is: how to run graphical applications within docker?

I remember I’ve recently managed to accomplish this in another linux distribution, but now I think I am missing something.

Thanks

You might need --privileged on the docker run.

Thanks znmeb, unfortunately it did not help.

giacomo@woody ~ $ docker run --rm --interactive  --privileged --env="DISPLAY" --env="QT_X11_NO_MITSHM=1"  --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw"    sshipway/xclock 
Error: Can't open display: :0

Thanks for any other advice
G

@Giacomo_S I tried the image and was able to get it to work with this command:

xhost +
docker run --rm --interactive --env=DISPLAY=$DISPLAY --env=QT_X11_NO_MITSHM=1 --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw sshipway/xclock

Also, be careful copy+pasting commands that contain quotation marks from the Internet. Sometimes the formatting can inadvertently change it from a straight quote character to a curly quote character.

Thanks @puneetse, this does not work for me.
I must be missing something…
See the attached screenshot.
Let me know if you need more detailed information about my Clear Linux installation.
Giacomo.

hi @Giacomo_S, do you see any difference on GNOME on X instead of Wayland or is the error the same? I am running Clear Linux version 29860 on an Intel NUC, and was able to launch the clock with your original command:
xhost +
docker run --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix sshipway/xclock

But I’m running on X not Xwayland. Can you take a look at this StackExchange issue and see if it applies?

Dear @bdeandocker_Xorg

Unfortunately, the result is exactly the same.

I take the opportunity to ask whether docker is the right tool for graphical applications or if there’s something more appropriate.
Thanks for helping solve this issue.
G.

Hello again Dear Clear Linux users and developers.
So, as to my topic, do you think docker is the appropriate tool to distribute graphical applications?
Is there something more tailored to this purpose?
I still haven’t solved the issue. If I am using docker out of its capabilities, I’ll have to find another solution, otherwise I will have to try another Linux distro to see if that configuration allows me to run graphical UIs from docker.
Thanks.

Can you check the output of sudo swupd bundle-list for containers-virt or cloud-native-basic? I’m wondering if your docker runtime is being defaulted to kata, which happens when those bundles are installed. Kata isolates containers inside lightweight VMs. If it is, you can try running the container with the --runtime=runc parameter to use the regular Docker runtime.

As to whether Docker is a good tool for distributing your graphical application, I think it depends a lot on your application and its requirements.

1 Like

Thanks @puneetse.

This is the (unsuccessful) result.

Giacomo

giacomo@woody ~/Downloads $
giacomo@woody ~/Downloads $ docker ps -a
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS                      PORTS               NAMES
c1abd6038d2c        cpascual/taurus-test:debian-stretch   "/usr/bin/supervisord"   2 weeks ago         Exited (0) 15 seconds ago                       taurus-stretch
giacomo@woody ~/Downloads $
giacomo@woody ~/Downloads $ xhost +
access control disabled, clients can connect from any host
giacomo@woody ~/Downloads $ docker run --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix sshipway/xclock --runtime=runc
Error: Can't open display: :0
giacomo@woody ~/Downloads $ 
giacomo@woody ~/Downloads $
giacomo@woody ~/Downloads $ sudo swupd bundle-list |grep containers
containers-basic
containers-virt
giacomo@woody ~/Downloads $ sudo swupd bundle-list |grep cloud
giacomo@woody ~/Downloads $ 

Best regards

Giacomo

Thanks for sharing that output. It is helpful to know that you have containers-virt installed, which installs kata as the default runtime as I suspected.

Try adding the --runtime=runc earlier in the docker run command. I think it doesn’t get comprehended if it’s added after the docker image name. This command worked for me with containers-virt installed for example:

xhost +
docker run --rm --runtime=runc --interactive --env=DISPLAY=$DISPLAY --env=QT_X11_NO_MITSHM=1 --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw sshipway/xclock

And/or, you can remove the containers-virt bundle to avoid the issue (sudo swupd bundle-remove containers-virt && sudo systemctl daemon-reload && sudo systemctl restart docker)

Fingers cross that it works for you this time :slight_smile: