ウィンドウマネージャなしで物理的に接続されたモニタにGUI LXCコンテナを表示するにはどうすればよいですか?

ウィンドウマネージャなしで物理的に接続されたモニタにGUI LXCコンテナを表示するにはどうすればよいですか?

特定のモニタでフルスクリーンを実行するLXC OSコンテナがある設定が必要です。中間ステップで、ホストXを介して表示するコンテナのXアプリケーションを取得しようとしています。

私はこれをガイドとして使ってきました:https://blog.simos.info/running-x11-software-in-lxd-containers/

私のプログラムは次のとおりです

X11コンテナを実行するための設定ファイルを作成します。

cat<<EOF>x11.profile
config:
  environment.DISPLAY: :0
  environment.PULSE_SERVER: unix:/home/ubuntu/pulse-native
  nvidia.driver.capabilities: all
  nvidia.runtime: "true"
  user.user-data: |
    #cloud-config
    runcmd:
      - 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'
    packages:
      - x11-apps
      - mesa-utils
      - pulseaudio
description: GUI LXD profile
devices:
  PASocket1:
    bind: container
    connect: unix:/run/user/1000/pulse/native
    listen: unix:/home/ubuntu/pulse-native
    security.gid: "1000"
    security.uid: "1000"
    uid: "1000"
    gid: "1000"
    mode: "0777"
    type: proxy
  X0:
    bind: container
    connect: unix:@/tmp/.X11-unix/X0
    listen: unix:@/tmp/.X11-unix/X0
    security.gid: "1000"
    security.uid: "1000"
    type: proxy
  mygpu:
    type: gpu
name: x11
used_by: []
EOF


lxc profile create x11
cat x11.profile | lxc profile edit x11

その後、コンテナを作成できます(Xを起動する必要がありますが、最初はこれが必要であることを知りませんでした)。

$ lxc launch ubuntu:18.04 --profile default --profile x11 mycontainer
Creating mycontainer
Starting mycontainer
Error: Failed to run: /snap/lxd/current/bin/lxd forkstart mycontainer /var/snap/lxd/common/lxd/containers /var/snap/lxd/common/lxd/logs/mycontainer/lxc.conf: 
Try `lxc info --show-log local:mycontainer` for more info


$ sudo startx &
[1] 12745
$ 
X.Org X Server 1.20.11
X Protocol Version 11, Revision 0
Build Operating System: linux Ubuntu
Current Operating System: Linux virtland 5.11.0-40-generic #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64
Kernel command line: BOOT_IMAGE=/BOOT/ubuntu_2aec3h@/vmlinuz-5.11.0-40-generic root=ZFS=rpool/ROOT/ubuntu_2aec3h ro init_on_alloc=0 amd_iommu=on vfio_pci.ids=10de:1b81,10de:10f0,1002:67df,1002:aaf0,1b21:1242 crashkernel=512M-:192M
Build Date: 06 July 2021  10:17:51AM
xorg-server 2:1.20.11-1ubuntu1~20.04.2 (For technical support please see http://www.ubuntu.com/support) 
Current version of pixman: 0.38.4
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Wed Nov 17 18:29:01 2021
(==) Using config file: "/etc/X11/xorg.conf"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
$ lxc launch ubuntu:18.04 --profile default --profile x11 mycontainer
Creating mycontainer
Starting mycontainer

コンテナ内でxeyesを実行すると、モニタに接続できなくなります。

以前のインストールではこれを使用しました(ホストデスクトップにxeyesが表示されますが、デスクトップがない場合はxeyesの代わりにデフォルトのxtermウィンドウがポップアップされます)。しかし、何らかの理由で今はまったく機能しません。私が何をしているのか理解していないと思います。

~$ lxc exec mycontainer -- sudo --user ubuntu --login
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@mycontainer:~$ xeyes
No protocol specified
Error: Can't open display: :0

だからまず、私はxeyesコンソールデスクトップに戻ってもらいたいです。

結局、私はウィンドウマネージャなしでベアXで実行でき、最終的にはそのプロセスを使用してDE全体を実行できるようにしたいと思います。

システム情報:オペレーティングシステム:Ubuntu Server 20.04 LXDバージョン:4.20 LXCバージョン:4.20

ベストアンサー1

私はついにここで答えを見つけました。「ルート」:「指定されたプロトコルなし」でGUIアプリケーションを実行できないのはなぜですか?

ただ実行しました。

sudo startx & #I'm pretty sure it isn't ideal to startx as root
sudo -i
xhost si:localuser:MYUSERID
exit

その後、コンテナに移動して実行すると、ウィンドウマネージャではxeyesなくディスプレイに表示されます。私がした他の何が影響を与えたのか分かりません。このラウンドでは、次のドライバをインストールしました。

sudo apt install --no-install-recommends nvidia-driver-470-server nvidia-utils-470-server nvidia-prime xfonts-base libc-dev libc6-dev fakeroot build-essential gnupg2 dbus-user-session mesa-vulkan-drivers

私はこれらすべてが必要かどうか疑問に思います。しかし、事実と迷信を経験的に分離する時間や忍耐はありません。それがうまくいけばそれで十分です。

おすすめ記事