AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1244329
Accepted
N0rbert
N0rbert
Asked: 2020-05-28 13:23:07 +0800 CST2020-05-28 13:23:07 +0800 CST 2020-05-28 13:23:07 +0800 CST

如何使用 Qt 和 D-Bus 在 Docker 容器中正确运行图形应用程序?

  • 772

我试图让 Audex在 20.04 LTS 主机上的 16.04 LTS Docker 容器中运行。

以下方法适用于基于 Gtk 的应用程序,我已经测试过了。

在当前情况下,我做了以下事情:

sudo apt-get update
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

然后尝试从终​​端启动它并得到输出:

$ 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.  

或者

$ 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.```

或者

$ 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.  

并且未显示应用程序窗口。

我想我在这里的 D-Bus 有问题。我们该如何解决?


更新,遵循下面的@SimonSudler回答:

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

QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
Error: Can not find password entry for uid 1000.
trying to create local folder //.kde: Permission denied
audex(7)/KSharedDataCache KSharedDataCache::Private::mapSharedMemory: Failed to establish shared memory mapping, will fallback to private memory -- memory usage will increase 
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     display this help and exit
      --version  output version information and exit

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report mv translation bugs to <http://translationproject.org/team/>
Full documentation at: <http://www.gnu.org/software/coreutils/mv>
or available locally via: info '(coreutils) mv invocation'
audex(7)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
Error: Can not find password entry for uid 1000.
X Error: BadAccess (attempt to access private resource denied) 10
  Extension:    130 (MIT-SHM)
  Minor opcode: 1 (X_ShmAttach)
  Resource id:  0x12d
X Error: BadShmSeg (invalid shared segment parameter) 128
  Extension:    130 (MIT-SHM)
  Minor opcode: 5 (X_ShmCreatePixmap)
  Resource id:  0x3a00017
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x3a00018
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x3a00018
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x3a00018
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x3a00018

添加--ipc=host也无济于事:

$ docker run --ipc=host -e DISPLAY -e DBUS_SESSION_BUS_ADDRESS     -v /tmp/.X11-unix:/tmp/.X11-unix -v /run:/run     --user="$(id --user):$(id --group)"     --security-opt apparmor=unconfined     ubuntu:audex
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
Error: Can not find password entry for uid 1000.
trying to create local folder //.kde: Permission denied
audex(7)/KSharedDataCache KSharedDataCache::Private::mapSharedMemory: Failed to establish shared memory mapping, will fallback to private memory -- memory usage will increase 
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     display this help and exit
      --version  output version information and exit

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report mv translation bugs to <http://translationproject.org/team/>
Full documentation at: <http://www.gnu.org/software/coreutils/mv>
or available locally via: info '(coreutils) mv invocation'
audex(7)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
Error: Can not find password entry for uid 1000.
qt dbus 16.04 docker 20.04
  • 1 1 个回答
  • 2163 Views

1 个回答

  • Voted
  1. Best Answer
    Simon Sudler
    2020-06-13T00:37:26+08:002020-06-13T00:37:26+08:00

    运行没有 apparmor 配置文件的容器

    原因是 apparmor 的docker-default配置文件。规则通过此模板集成到 docker 守护程序中。

    有一种快速验证方法,如果此配置文件导致问题,请将其添加--security-opt apparmor=unconfined到run命令中:

    docker run -e DISPLAY -e DBUS_SESSION_BUS_ADDRESS \
        -v /tmp/.X11-unix:/tmp/.X11-unix -v /run:/run \
        --user="$(id --user):$(id --group)" \
        --security-opt apparmor=unconfined \
        -v /dev/sr0:/dev/sr0 \
        -v /dev/cdrom:/dev/cdrom \
        --privileged \
        ubuntu:audex
    

    您可以开始为 audex 编写 apparmor 配置文件,但我认为这不值得。由于audix是 CD 开膛手,因此用户需要一些“特权”访问才能将 CD 插入/取出 PC。所以使用apparmor=unconfined应该足够安全。

    Audex的核心转储

    启动时audex,它会执行几个预期是编码器的命令(例如faac --help)。由于某种原因,它也会执行mv --help,这会产生奇怪的输出。至少这似乎不是问题的一部分。此外,此行为仅在~/.kde/share/config/audexrc写入文件之前发生。在那之后,只剩下崩溃了……

    查看 audex 的核心转储:

    gdb /usr/bin/audex core.audex.3225
    ...
    (gdb) bt
    #0  0x00007f8799abda7f in KUrl::KUrl(QString const&) () from /usr/lib/libkdecore.so.5
    #1  0x00007f879b4c7245 in KCompactDisc::cdromDeviceUrl(QString const&) () from /usr/lib/libkcompactdisc.so.4
    #2  0x0000000000423469 in MainWindow::MainWindow (this=0x23ef580, parent=<optimized out>, __in_chrg=<optimized out>, 
        __vtt_parm=<optimized out>) at /build/buildd/audex-0.78/mainwindow.cpp:39
    #3  0x000000000041a159 in main (argc=3, argv=0x7ffd939ccf58) at /build/buildd/audex-0.78/main.cpp:46
    

    audix我在尝试读取 CD-ROM 设备 URL 时接缝死了。我添加了/dev/sr0and/dev/cdrom来适应它,但它没有任何效果(请参阅 docker 的 handbreak 示例)。audex将容器中的用户添加到cdrom组中也没有帮助。

    这似乎是 16.04 旧版本中的一个错误audix,它需要一个旧的 URL 字符串。

    由于缺少一些“旧”的 KDE 行为,可能无法在当前的 Ubuntu 系统上运行audex。ubuntu:16.04然而,有一个来自 KDE 的Neon/Docker,但它还需要主机上的 KDE。

    • 1

相关问题

  • 从 ubuntu 切换到 kubuntu。要使用哪些应用程序?

  • 查看我可以发送到应用程序的可用 DBUS 消息的工具

  • 新的 Unity 桌面会在 Qt 中编程吗?

  • Google 地球和 Skype 主题

  • 如何使用类似 Qt 的 UI 在 KDE 中运行 Java 应用程序?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve