本文介绍了在Docker中运行Chromium-Gtk:无法打开显示:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在docker容器中运行Chrome时,我看到以下错误:Gtk:无法打开显示:0:0

When I try to run chromium inside a docker container I see the following error: Gtk: cannot open display: :0

Dockerfile:(基于 https://registry.hub.docker.com/u/jess/chromium/dockerfile

Dockerfile: (based on https://registry.hub.docker.com/u/jess/chromium/dockerfile)

FROM debian:jessie

# Install Chromium
RUN sed -i.bak 's/jessie main/jessie main contrib non-free/g' /etc/apt/sources.list && \
    apt-get update && apt-get install -y \
    chromium \
    chromium-l10n \
    libcanberra-gtk-module \
    libexif-dev \
    libpango1.0-0 \
    libv4l-0 \
    pepperflashplugin-nonfree \                                                                          
    --no-install-recommends && \
    mkdir -p /etc/chromium.d/

# Autorun x11vnc
CMD ["/usr/bin/chromium", "--no-sandbox", "--user-data-dir=/data"]

构建并运行:

docker build -t chromium
docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --privileged chromium

和错误:

[1:1:0202/085603:ERROR:browser_main_loop.cc(164)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
No protocol specified
[1:1:0202/085603:ERROR:browser_main_loop.cc(210)] Gtk: cannot open display: :0


推荐答案

我对铬不太了解,但是当:-)时,我确实使用X进行了研究。告诉X客户端连接到:0,您的意思是连接到端口6000(或运行X服务器的任何设备)+ 0,或者连接到端口6000。实际上,DISPLAY是IP:PORT(如上所述为+6000)。 X服务器正在您的主机上运行,​​因此,如果您进行以下设置:

i don't know much about chromium, but, I did work with X way back when :-) When you tell an X client to connect to :0, what you are saying is connect to port 6000 (or whatever your X server runs on) + 0, or port 6000 in this case. In fact, DISPLAY is IP:PORT (with the +6000 as mentioned above). The X server is running on your host, so, if you set:

DISPLAY=your_host_ip:0

可能有效。但是,X服务器不允许仅来自任何旧客户端的连接,因此,您将需要打开X服务器。在主机上运行

that might work. However, X servers did not allow connections from just any old client, so, you will need to open up your X server. on your host, run

xhost +

在运行Docker容器之前。所有这些都是假设您可以在主机上运行Chrome(即,主机上存在X服务器)。

before running the docker container. All of this is assuming you can run chromium on your host (that is, an X server exists on your host).

这篇关于在Docker中运行Chromium-Gtk:无法打开显示:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 04:31