你可以在 Linux Docker 容器中运行 GUI 应用程序吗? [英] Can you run GUI applications in a Linux Docker container?

查看:111
本文介绍了你可以在 Linux Docker 容器中运行 GUI 应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Linux Docker 容器中运行 GUI 应用程序?

How can you run GUI applications in a Linux Docker container?

是否有任何图像可以设置 vncserver 或其他东西,以便您可以 - 例如 - 在 Firefox 周围添加一个额外的加速沙箱?

Are there any images that set up vncserver or something so that you can - for example - add an extra speedbump sandbox around say Firefox?

推荐答案

你可以简单地安装一个 vncserver 和 Firefox :)

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

这篇关于你可以在 Linux Docker 容器中运行 GUI 应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆