[Tutorials] 使用Dockerfile创建一个代桌面环境的DOCKER
Tofloor
poster avatar
酷谷的谷子
deepin
2025-08-10 13:53
Author

这个是使用豆包生成的,如果你有自己的Dockerfile可以改个后最丢.txt给豆包提一个需求

帮重新写这个Dockerfile要求安装一个好看的桌面环境,支持web链接管理

如果你不太了解DOCKER我这里有一些以前收集的资料 如果你一点都不懂可以问我

docker使用资料.zip

####################################################
# 基于Ubuntu 18.04构建带Xfce桌面和Web管理的镜像
# 构建命令: docker build --no-cache -t ubuntu/xfce-web:1.0 .
# 运行容器: docker run -itd -p 5901:5901 -p 6080:6080 --name xfce-web ubuntu/xfce-web:1.0
# Web访问: http://localhost:6080 (默认VNC密码: 123456)
# 在执行命令后面不要加注释否则会报错
####################################################
FROM ubuntu:18.04
MAINTAINER i8520

# 环境变量配置
ENV DEBIAN_FRONTEND=noninteractive \
    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin \
    DISPLAY=:1 \
    VNC_PORT=5901 \
    NO_VNC_PORT=6080 \
    VNC_PW=123456  # 可自行修改VNC密码

# 预先配置键盘布局,避免交互式提问
RUN echo "keyboard-configuration keyboard-configuration/layoutcode string us" | debconf-set-selections && \
    echo "keyboard-configuration keyboard-configuration/modelcode string pc105" | debconf-set-selections

# 复制资源文件
COPY SR /
RUN mv /MYStart /bin  

# 替换APT源并更新系统
RUN cp -r /etc/apt/sources.list /etc/apt/sources.list_bak && \
    mv /sources.list /etc/apt && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    apt update -y && apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"

# 安装基础工具链
RUN apt install -y \
    apt-file iproute2 net-tools iputils-ping libsasl2-dev init openssh-server \
    vim sudo p7zip-full curl zip unzip wget expect psmisc fuse fontconfig \
    language-pack-zh-hans autoconf g++ make pkg-config && \
    rm -rf /var/lib/apt/lists/*

# 安装Xfce桌面环境 (美观轻量)
RUN apt update -y && \
    apt install -y \
    xfce4 xfce4-goodies xorg dbus-x11 x11-utils x11-apps \
    # 桌面美化组件
    gtk2-engines-murrine gtk3-engines-unico numix-gtk-theme numix-icon-theme \
    # VNC服务与Web访问支持
    tigervnc-standalone-server novnc websockify && \
    rm -rf /var/lib/apt/lists/*

# 安装Web链接管理工具与浏览器
RUN apt update -y && \
    apt install -y \
    firefox \
    linkhandler \
    cherrytree && \
    rm -rf /var/lib/apt/lists/*

# 配置中文字体
RUN mkdir -p /usr/share/fonts/my_fonts && \
    mv /simsun.ttc /usr/share/fonts/my_fonts && \
    apt install -y fonts-wqy-microhei fonts-wqy-zenhei fonts-arphic-ukai fonts-arphic-uming && \
    cd /usr/share/fonts/my_fonts && \
    mkfontscale && mkfontdir && fc-cache -fv && \
    rm -rf /var/lib/apt/lists/*

# 配置VNC服务
RUN mkdir -p /root/.vnc && \
    echo "$VNC_PW" | vncpasswd -f > /root/.vnc/passwd && \
    chmod 600 /root/.vnc/passwd && \
    echo '#!/bin/bash' > /root/.vnc/xstartup && \
    echo 'xrdb $HOME/.Xresources' >> /root/.vnc/xstartup && \
    echo 'startxfce4 &' >> /root/.vnc/xstartup && \
    chmod +x /root/.vnc/xstartup

# 配置noVNC (Web访问VNC)
RUN ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html && \
    echo '#!/bin/bash' > /start.sh && \
    echo 'vncserver :1 -geometry 1280x720 -depth 24' >> /start.sh && \
    echo 'websockify -D --web=/usr/share/novnc $NO_VNC_PORT localhost:$VNC_PORT' >> /start.sh && \
    echo '/bin/MYStart' >> /start.sh && \
    echo '/bin/bash' >> /start.sh && \
    chmod +x /start.sh

# 暴露端口
EXPOSE $VNC_PORT $NO_VNC_PORT

# 启动服务
CMD ["/start.sh"]

Reply Favorite View the author
All Replies
耀眼的明星
deepin
2025-08-11 08:19
#1

V25版本我安装了docker和1panel 可后者安装完成启动失败。命令启动后,又不显示管理网址。。。

Reply View the author
酷谷的谷子
deepin
2025-08-11 09:29
#2
耀眼的明星

V25版本我安装了docker和1panel 可后者安装完成启动失败。命令启动后,又不显示管理网址。。。

可能根磐石有点关系,我在Mint上没有这样的问题

这个是官方的排查方法

https://bbs.fit2cloud.com/t/topic/1069

https://www.doubao.com/thread/w03af101578c7257a

Reply View the author