Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # jianboy/ubuntu-vnc:latest
  2. FROM ubuntu:24.04
  3. WORKDIR /app
  4. # apt replace aliyun source
  5. RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
  6. RUN apt update && apt install -y xfce4 tightvncserver xrdp \
  7. xfce4-goodies \
  8. novnc \
  9. x11vnc \
  10. wget \
  11. curl \
  12. firefox \
  13. net-tools \
  14. xorg \
  15. openbox \
  16. supervisor
  17. # && apt-get clean \
  18. # && rm -rf /var/lib/apt/lists/*
  19. # 安装noVNC
  20. RUN wget https://github.com/novnc/noVNC/archive/refs/tags/v1.2.0.tar.gz && \
  21. tar -xvzf v1.2.0.tar.gz && \
  22. mv noVNC-1.2.0 /opt/noVNC
  23. ENV VNC_PASSWORD=123456
  24. ENV DISPLAY=:0
  25. # 创建启动脚本
  26. RUN echo '#!/bin/bash\n\
  27. x11vnc -storepasswd $VNC_PASSWORD ~/.vnc/passwd\n\
  28. # 启动 supervisord\n\
  29. exec /usr/bin/supervisord' > /start.sh && \
  30. chmod +x /start.sh
  31. # 配置 supervisord 来启动服务
  32. RUN echo "[supervisord]\nnodaemon=true" > /etc/supervisor/conf.d/supervisord.conf && \
  33. echo "[program:x11]\ncommand=startx\n" >> /etc/supervisor/conf.d/supervisord.conf && \
  34. echo "[program:x11vnc]\ncommand=x11vnc -display :0 -forever -usepw -create\n" >> /etc/supervisor/conf.d/supervisord.conf && \
  35. echo "[program:noVNC]\ncommand=/opt/noVNC/utils/launch.sh --vnc localhost:5900" >> /etc/supervisor/conf.d/supervisord.conf
  36. RUN mkdir -p ~/.vnc
  37. RUN echo "xfce4-session" > ~/.xsession
  38. EXPOSE 5900 6080
  39. # CMD ["vncserver", ":1"]
  40. # CMD ["/usr/sbin/xrdp", "-n"]
  41. # CMD ["/usr/bin/supervisord"]
  42. CMD ["/start.sh"]
  43. # docker build -t jianboy/ubuntu-vnc:latest .
  44. # docker run -d --rm -v ./:/app -p 3389:3389 -p 5900:5900 -p 6080:6080 -e VNC_PASSWORD=123456 --name ubuntu-vnc aa:latest
  45. # docker exec -it ubuntu-vnc netstat -tuln | grep 5900
  46. # docker exec -it ubuntu-vnc /opt/noVNC/utils/launch.sh --vnc localhost:5900
  47. # docker exec -it ubuntu-vnc curl http://localhost:6080
  48. # docker exec -it ubuntu-vnc bash
  49. # startxfce4