1. 程式人生 > >Docker容器中如何執行一個帶GUI的app?

Docker容器中如何執行一個帶GUI的app?

640?wx_fmt=png&wxfrom=5&wx_lazy=1

問:

How can you run GUI apps in a docker container?

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

答:

You can simply install a vncserver along with firefox :)

I pushed an image vnc/firefox here: docker pull creack/firefox-vnc

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'


This will create a docker container running vnc with the password 1234:

For docker version 1.3 or newer:

docker run -p 5900 -e HOME=/ creack/firefox-vnc x11vnc -forever -usepw -create

For docker before version 1.3:

docker run -p 5900 creack/firefox-vnc x11vnc -forever -usepw -create

原連結:

https://stackoverflow.com/questions/16296753/can-you-run-gui-apps-in-a-docker-container#

0?wx_fmt=gif

點選閱讀原文,一起玩耍