您的位置:首页 > 运维架构 > Docker

图像化界面 显示firefox浏览器

2017-10-16 19:21 323 查看

Dockerfile文件

#!/bin/bash
FROM centos:7
RUN yum install -y firefox
####用你自己的 uid /gid 替换下面的0
RUN export uid=0 gid=0
RUN mkdir -p /home/developer
RUN echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash">>/etc/passwd
RUN echo "developer:x:${uid}:">>/etc/group
RUN echo "developer ALL=(ALL) NOPASSWD: ALL">>/etc/sudoers
RUN chmod 0440 /etc/sudoers
RUN chown ${uid}:${gid} -R  /home/developer
USER developer
ENV HOME /home/developer
CMD /usr/bin/firefox


注意:在第四行的配置中,用你自己的用户和组id来替换0。 我们可以用下面的命令在shell或者终端中得到uid和gid。

# id $USER


构造Docker容器

# docker build --rm -t firefox .


运行Docker容器

# docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix firefox


The next I tried to run the same container with -u 0 to become root and after i tried to start the application the following error message appears:

No protocol specified
QXcbConnection: Could not connect to display :0
Aborted (core dumped)


The Solution of the problem:

Give docker the rights to access the X-Server with:

#xhost +local:docker
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  docker
相关文章推荐