#StackBounty: #16.04 #20.04 #docker #qt #dbus How to correctly run graphical application in Docker container with Qt and D-Bus?

Bounty: 50

I was trying to get Audex running inside 16.04 LTS Docker container on the 20.04 LTS host.

The below method works normally for Gtk-based applications, I have tested it.

In current case I did the following:

sudo apt-get install docker.io
sudo usermod -a -G docker $USER
# reboot

mkdir ~/docker-audex
cat > ~/docker-audex/Dockerfile << EOF
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y audex
CMD audex
EOF

docker build -t ubuntu:audex ~/docker-audex

Then try to launch it from terminal and got the output:

$ docker run -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --user="$(id --user):$(id --group)" ubuntu:audex 
QDBusConnection: session D-Bus connection created before QCoreApplication. Application
may misbehave. audex(7): KUniqueApplication: Cannot find the D-Bus
session server:  "/usr/bin/dbus-launch terminated abnormally with the
following error: Autolaunch error: X11 initialization failed. " 

audex(6): KUniqueApplication: Pipe closed unexpectedly.  

or

$ docker run -e DISPLAY -e DBUS_SESSION_BUS_ADDRESS -v /tmp/.X11-unix:/tmp/.X11-unix --user="$(id --user):$(id --group)" ubuntu:audex

QDBusConnection: session D-Bus connection created before
QCoreApplication. Application may misbehave. audex(7):
KUniqueApplication: Cannot find the D-Bus session server:  "Failed to
connect to socket /run/user/1000/bus: No such file or directory" 

audex(6): KUniqueApplication: Pipe closed unexpectedly.```

or

$ docker run -e DISPLAY -e DBUS_SESSION_BUS_ADDRESS -v /tmp/.X11-unix:/tmp/.X11-unix -v /run:/run --user="$(id --user):$(id --group)" ubuntu:audex
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave. audex(7):
KUniqueApplication: Cannot find the D-Bus session server:  "An
AppArmor policy prevents this sender from sending this message to this
recipient; type="method_call", sender="(null)" (inactive)
interface="org.freedesktop.DBus" member="Hello" error name="(unset)"
requested_reply="0" destination="org.freedesktop.DBus" (bus)" 

audex(6): KUniqueApplication: Pipe closed unexpectedly.  

and application window was not shown.

I suppose I have a problem with D-Bus here. How can we fix it?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.