From c0b7f4ca4fe21ae6ce892eb2ea54ee7c06bdff28 Mon Sep 17 00:00:00 2001 From: ZacharyZcR <2903735704@qq.com> Date: Fri, 20 Dec 2024 03:01:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0VNC=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=9D=B6=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestDocker/VNC/Dockerfile | 45 +++++++++++++++++++++++++++++++++ TestDocker/VNC/supervisord.conf | 8 ++++++ 2 files changed, 53 insertions(+) create mode 100644 TestDocker/VNC/Dockerfile create mode 100644 TestDocker/VNC/supervisord.conf diff --git a/TestDocker/VNC/Dockerfile b/TestDocker/VNC/Dockerfile new file mode 100644 index 0000000..2cebf04 --- /dev/null +++ b/TestDocker/VNC/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu:20.04 + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=Asia/Shanghai + +# 安装必要的包 +RUN apt-get update && apt-get install -y \ + tightvncserver \ + xfce4 \ + xfce4-terminal \ + supervisor + +# 创建新用户 +RUN useradd -m vncuser +ENV USER=vncuser +ENV HOME=/home/vncuser + +# 设置supervisor配置 +RUN mkdir -p /var/log/supervisor +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# 切换到vncuser用户 +USER vncuser +WORKDIR /home/vncuser + +# 创建必要的文件和目录 +RUN touch ~/.Xauthority +RUN mkdir -p ~/.vnc + +# 创建启动脚本 +RUN echo '#!/bin/bash\nxrdb $HOME/.Xresources\nstartxfce4 &' > ~/.vnc/xstartup +RUN chmod +x ~/.vnc/xstartup + +# 设置VNC密码 +RUN echo "123456" | vncpasswd -f > ~/.vnc/passwd +RUN chmod 600 ~/.vnc/passwd + +# 切回root用户来运行supervisor +USER root + +# 暴露VNC端口 +EXPOSE 5901 + +# 使用supervisor启动服务 +CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/TestDocker/VNC/supervisord.conf b/TestDocker/VNC/supervisord.conf new file mode 100644 index 0000000..2d04195 --- /dev/null +++ b/TestDocker/VNC/supervisord.conf @@ -0,0 +1,8 @@ +[supervisord] +nodaemon=true + +[program:vnc] +command=/usr/bin/vncserver :1 -geometry 1280x800 -depth 24 +user=vncuser +autostart=true +autorestart=true \ No newline at end of file