这就是我一直在寻找的最简单的形式desktop在 Docker 中:
FROM ubuntu
RUN apt-get update
RUN apt-get install xfce4 -y
RUN apt-get install xfce4-goodies -y
RUN apt-get purge -y pm-utils xscreensaver*
RUN apt-get install wget -y
EXPOSE 5901
RUN wget -qO- https://dl.bintray.com/tigervnc/stable/tigervnc-1.8.0.x86_64.tar.gz | tar xz --strip 1 -C /
RUN mkdir ~/.vnc
RUN echo "123456" | vncpasswd -f >> ~/.vnc/passwd
RUN chmod 600 ~/.vnc/passwd
CMD ["/usr/bin/vncserver", "-fg"]
不幸的是我无法解决x11vnc and xvfb. But TigerVNC http://tigervnc.org/结果好多了。
此示例使用 xfce gui 生成容器并运行虚拟网络服务器密码为123456。有no need覆盖〜/.vnc/xstartup手动,因为 TigerVNC 默认启动 X 服务器!
运行服务器:
sudo docker run --rm -dti -p 5901:5901 3ab3e0e7cb
在那里连接虚拟网络查看器 http://tigervnc.org/doc/vncviewer.html:
vncviewer -AutoSelect 0 -QualityLevel 9 -CompressLevel 0 192.168.1.100:5901
Also you could not care about screen resolution because by default it will resize to fit your screen:
您可能还会遇到ipc_channel_posix 问题 https://github.com/SeleniumHQ/docker-selenium/issues/388(chrome和其他浏览器将无法正常工作)消除这个运行容器内存共享 https://github.com/SeleniumHQ/docker-selenium#running-the-images:
docker run -d --shm-size=2g --privileged -p 5901:5901 image-name