如何在Linux容器中运行Docker应用程序?
有没有设置vncserver之类的图片,比如,在火狐周围添加一个额外的高速沙箱?
发布于 2013-05-01 00:55:28
您可以简单地安装一个vncserver和Firefox :)
我推了一个图片,vnc/firefox,在这里:docker pull creack/firefox-vnc
这个映像是用这个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'这将创建一个使用密码1234运行VNC的Docker容器。
关于Docker版本18或更高版本:
docker run -p 5900:5900 -e HOME=/ creack/firefox-vnc x11vnc -forever -usepw -create对于Docker版本1.3或更高版本:
docker run -p 5900 -e HOME=/ creack/firefox-vnc x11vnc -forever -usepw -create在1.3版之前的Docker:
docker run -p 5900 creack/firefox-vnc x11vnc -forever -usepw -create发布于 2014-08-13 07:33:45
Xauthority成为新系统的一个问题。我可以在运行我的码头容器之前放弃使用xhost +的任何保护,或者我可以传递一个准备良好的Xauthority文件。典型的Xauthority文件是主机名特定的。使用docker,每个容器都可以有不同的主机名(使用docker运行-h设置),但是即使设置与主机系统相同的容器主机名在我的情况下也没有帮助。xeyes (我喜欢这个例子)只会忽略神奇的cookie,而不会将凭据传递给服务器。因此,我们得到一条错误消息:“没有指定的协议不能打开显示”
Xauthority文件可以以某种方式编写,这样主机名就不重要了。我们需要将认证家庭设置为“家庭野生”。我不确定,xauth是否有一个正确的命令行,所以这里有一个将xauth和sed结合起来的示例。我们需要更改nlist输出的前16位。FamilyWild的值为65535或0 0xffff。
docker build -t xeyes - << __EOF__
FROM debian
RUN apt-get update
RUN apt-get install -qqy x11-apps
ENV DISPLAY :0
CMD xeyes
__EOF__
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run -ti -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH xeyes发布于 2015-03-10 18:28:44
我刚找到这篇博文,想在这里和大家分享,因为我认为这是最好的方法,而且很简单。
http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
优点:
缺点:
如果有一天链接失败,我把最重要的部分放在这里:
码头文件:
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y firefox
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer
USER developer
ENV HOME /home/developer
CMD /usr/bin/firefox建立形象:
docker build -t firefox .和run命令:
docker run -ti --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
firefox当然,您也可以使用sh -c "echo script-here"在run命令中这样做。
提示:关于音频,请看:https://stackoverflow.com/a/28985715/2835523
https://stackoverflow.com/questions/16296753
复制相似问题