您可以在Docker容器中运行GUI应用程序吗? [英] Can you run GUI applications in a Docker container?
问题描述
如何在 Docker 容器中运行GUI应用程序?
How can you run GUI applications in a Docker container?
是否有任何设置 vncserver
的图像或其他东西,例如,您可以在Firefox周围添加一个额外的speedbump沙箱?
Are there any images that set up vncserver
or something so that you can - for example - add an extra speedbump sandbox around say Firefox?
推荐答案
您只需在Firefox上安装vncserver即可:)
You can simply install a vncserver along with Firefox :)
我推送了一个图像, vnc / firefox,在这里: docker pull creack / firefox-vnc
I pushed an image, vnc/firefox, here: docker pull creack/firefox-vnc
该镜像是使用此Dockerfile制作的:
The image has been made with this Dockerfile:
# Firefox over VNC
#
# VERSION 0.1
# DOCKER-VERSION 0.2
FROM ubuntu:12.04
# Make sure the package repository is up to date
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
# Install vnc, xvfb in order to create a 'fake' display and firefox
RUN apt-get install -y x11vnc xvfb firefox
RUN mkdir ~/.vnc
# Setup a password
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
# Autostart firefox (might not be the best way to do it, but it does the trick)
RUN bash -c 'echo "firefox" >> /.bashrc'
这将创建一个运行VNC且密码为的Docker容器1234
:
This will create a Docker container running VNC with the password 1234
:
对于Docker版本18或更高版本:
For Docker version 18 or newer:
docker run -p 5900:5900 -e HOME=/ creack/firefox-vnc x11vnc -forever -usepw -create
对于Docker 1.3或更高版本:
For Docker version 1.3 or newer:
docker run -p 5900 -e HOME=/ creack/firefox-vnc x11vnc -forever -usepw -create
对于1.3版之前的Docker:
For Docker before version 1.3:
docker run -p 5900 creack/firefox-vnc x11vnc -forever -usepw -create
这篇关于您可以在Docker容器中运行GUI应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!