容器的优势无需赘述。有些场景仍然需要一个桌面系统,比如桌面软件开发(flutter),交互式应用访问等(chrome)。
以下记录如何在容器中使用完整桌面环境过程(ubuntu 2404)
安装桌面环境
apt-get install -y --no-install-recommends xfce4
复制代码
安装 vncserver
apt install tigervnc-standalone-server
复制代码
设置 vncserver 密码
添加配置文件 nano ~/.vnc/xstartup
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4
复制代码
chmod u+x ~/.vnc/xstartup
使用 novnc
git clone https://github.com/novnc/noVNC.git
cd noVNC
./utils/novnc_proxy --vnc 0.0.0.0:5902 --listen 0.0.0.0:6081
复制代码
问题记录
安装,重启 vncserver
启动报错
[root@moodle-bak .X11-unix]# vncserver
WARNING: The first attempt to start Xvnc failed, possibly because the font
catalog is not properly configured. Attempting to determine an appropriate
font path for this system and restart Xvnc using that font path ...
Could not start Xvnc.
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
解决方法:
touch /tmp/.X11-unix/X1
chmod 777 /tmp/.X11-unix/X1
解决
复制代码
参考
https://www.cnblogs.com/liyuanhong/articles/15487147.html
https://aws.amazon.com/cn/blogs/china/how-to-build-access-to-the-ubuntu-22-desktop-through-a-browser-using-novnc/
评论