容器:无法启动 mutter(作为带有 gnome 会话的无头 Wayland 合成器)

容器:无法启动 mutter(作为带有 gnome 会话的无头 Wayland 合成器)

我想做的是

  • 一个容器(最好是 OCI 容器),无需将主机会话管理器接口暴露在“其中”即可工作,并且
  • 运行 Wayland 合成器
  • 有一个 >= gnome40 会话,其中包含所有 UI 元素
  • 允许通过 RDP 或 VNC 进行远程显示和交互

因此,这分别规定/建议作为工具:

  • podman
  • mutter(这就是 Gnome 想要的)
  • gnome-shell
  • gnome-remote-desktop,随 Gnome42 一起提供

我目前正在做的是

podman run -it --rm -p 9999:9999 ubuntu:22.04
#           ^---------------------------------Interactive
#               ^-----------------------------Don't keep state after finishing
#                    ^------------------------We'll need a port fwd into the container for RDP/VNC
#                                ^------------Not a great fan of Canonical, but 22.04 brings Gnome42

root@container$> apt update; apt install -y mutter gnome-remote-desktop gnome-shell
[… [success]]

root@container$> mutter --no-x11 --wayland --headless --virtual-monitor 1600x1000 
mutter-Message: 10:30:35.151: Running Mutter (using mutter 42.0) as a Wayland display server
mutter-Message: 10:30:35.191: Created surfaceless renderer without GPU
mutter-Message: 10:30:35.205: Disabling DMA buffer screen sharing (not hardware accelerated)
mutter-Message: 10:30:35.205: Added virtual monitor Meta-0

(mutter:13413): mutter-WARNING **: 10:30:35.211: WL: error: XDG_RUNTIME_DIR not set in the environment
(mutter:13413): mutter-ERROR **: 10:30:35.211: Failed to create socket
root@container$> export XDG_RUNTIME_DIR=/run/user/0/ ; mkdir -p ${XDG_RUNTIME_DIR}
root@container$> mutter --no-x11 --wayland --headless --virtual-monitor 1600x1000 
mutter-Message: 10:30:47.657: Running Mutter (using mutter 42.0) as a Wayland display server
mutter-Message: 10:30:47.698: Created surfaceless renderer without GPU
mutter-Message: 10:30:47.712: Disabling DMA buffer screen sharing (not hardware accelerated)
mutter-Message: 10:30:47.712: Added virtual monitor Meta-0
mutter-Message: 10:30:47.717: Using Wayland display name 'wayland-0'
**
mutter:ERROR:../src/wayland/meta-wayland.c:379:set_gnome_env: assertion failed: (session_bus)
Bail out! mutter:ERROR:../src/wayland/meta-wayland.c:379:set_gnome_env: assertion failed: (session_bus)

[1]+  Aborted                 (core dumped) mutter --sm-disable --no-x11 --wayland --headless --virtual-monitor 1600x1000

不太确定从这里去哪里。我应该直接启动 gnome shell 吗?

# fresh container to avoid any conflicts
root@7396d1bb8693:/> gnome-shell --no-x11 --wayland --headless --virtual-monitor 1600x1000
mutter-Message: 10:45:06.276: Running GNOME Shell (using mutter 42.0) as a Wayland display server
mutter-Message: 10:45:06.323: Created surfaceless renderer without GPU
mutter-Message: 10:45:06.337: Disabling DMA buffer screen sharing (not hardware accelerated)
mutter-Message: 10:45:06.338: Added virtual monitor Meta-0
Failed to connect to session bus: Cannot autolaunch D-Bus without X11 $DISPLAYroot@7396d1bb8693:/>

也不行。

  • 如何在非特权容器中启动无头 gnome wayland 会话?

答案1

我设法在 GitHub 操作上完成以下工作(不确定它是否像 OCI 一样没有特权,所以也许它不能完全适合你):

  run: |
    sudo apt-get install mutter dbus-x11;
    dbus-launch --auto-syntax > dbus-env;
    source dbus-env;
    mutter --no-x11 --headless --virtual-monitor 1920x1080 &

source dbus-env将为进一步的进程连接到显示器设置正确的环境变量。

相关内容