# jianboy/ubuntu-vnc:latest FROM ubuntu:24.04 WORKDIR /app # apt replace aliyun source RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list RUN apt update && apt install -y xfce4 tightvncserver xrdp \ xfce4-goodies \ novnc \ x11vnc \ wget \ curl \ firefox \ net-tools \ xorg \ openbox \ supervisor # && apt-get clean \ # && rm -rf /var/lib/apt/lists/* # 安装noVNC RUN wget https://github.com/novnc/noVNC/archive/refs/tags/v1.2.0.tar.gz && \ tar -xvzf v1.2.0.tar.gz && \ mv noVNC-1.2.0 /opt/noVNC ENV VNC_PASSWORD=123456 ENV DISPLAY=:0 # 创建启动脚本 RUN echo '#!/bin/bash\n\ x11vnc -storepasswd $VNC_PASSWORD ~/.vnc/passwd\n\ # 启动 supervisord\n\ exec /usr/bin/supervisord' > /start.sh && \ chmod +x /start.sh # 配置 supervisord 来启动服务 RUN echo "[supervisord]\nnodaemon=true" > /etc/supervisor/conf.d/supervisord.conf && \ echo "[program:x11]\ncommand=startx\n" >> /etc/supervisor/conf.d/supervisord.conf && \ echo "[program:x11vnc]\ncommand=x11vnc -display :0 -forever -usepw -create\n" >> /etc/supervisor/conf.d/supervisord.conf && \ echo "[program:noVNC]\ncommand=/opt/noVNC/utils/launch.sh --vnc localhost:5900" >> /etc/supervisor/conf.d/supervisord.conf RUN mkdir -p ~/.vnc RUN echo "xfce4-session" > ~/.xsession EXPOSE 5900 6080 # CMD ["vncserver", ":1"] # CMD ["/usr/sbin/xrdp", "-n"] # CMD ["/usr/bin/supervisord"] CMD ["/start.sh"] # docker build -t jianboy/ubuntu-vnc:latest . # docker run -d --rm -v ./:/app -p 3389:3389 -p 5900:5900 -p 6080:6080 -e VNC_PASSWORD=123456 --name ubuntu-vnc aa:latest # docker exec -it ubuntu-vnc netstat -tuln | grep 5900 # docker exec -it ubuntu-vnc /opt/noVNC/utils/launch.sh --vnc localhost:5900 # docker exec -it ubuntu-vnc curl http://localhost:6080 # docker exec -it ubuntu-vnc bash # startxfce4