目前用的ubuntu 22.04.4 LTS。
对于想在容器内跑gui程序,并在宿主机上使用,还是需要一些小调整的。首先,我们建一个gui的profile
incus profile create gui
incus profile edit gui
config:cloud-init.vendor-data: |#cloud-configpackages:- x11-apps- mesa-utils- pulseaudioruncmd:- 'sed -i "s/; enable-shm = yes/enable-shm = no/g" /etc/pulse/client.conf'- 'echo export PULSE_SERVER=unix:/tmp/.pulse-native | tee --append /home/ubuntu/.profile'environment.DISPLAY: :0raw.idmap: both 1000 1000description: GUI LXD profiledevices:PASocket:path: /tmp/.pulse-nativesource: /run/user/1000/pulse/nativetype: diskX0:path: /tmp/.X11-unix/X0source: /tmp/.X11-unix/X0type: diskmygpu:type: gpuname: gui
然后启动一个容器,我们就叫wechat吧
incus launch -p gui -p default images:ubuntu/22.04/cloud wechat -c security.nesting=true
如果用lxd,估计把images:ubuntu/22.04/cloud改成ubuntu:jammy就行了,因为lxd无法使用社区的镜像服务器
进入容器,开始准备安装包,先从 这里 下载最新版本deb包
incus shell wechatapt install -y gdebi-coregdebi /tmp/wechat-beta_1.0.0.145_amd64.fixed.deb
apt install -y libnss3 libxkbcommon0 libxkbcommon-x11-0 libxcb-xkb1 libxcb-icccm4 libxcb-render0 libxcb-image0 libxcb-shape0 libxcb-keysyms1 libxcb-render-util0 libatomic1 libxrandr2 libxcomposite1 libxdamage1 libpango-1.0-0 libcairo2 libatk1.0-0 libatk-bridge2.0-0 fonts-noto --install-recommends
su - ubuntuxdg-user-dirs-update
exit; exitincus exec wechat --user 1000 -- bash
echo $DISPLAY (应该是:0)