Chrome无法通过Docker容器内的调试端口提供服务

时间:2018-01-18 10:37:04

标签: google-chrome docker google-chrome-devtools remote-debugging

我有一个非常简单的docker容器,可以安装' google-chrome-stable'按照these instructions

在容器内部,我无法启动并访问调试服务器:

# start chrome in debug mode
$ google-chrome-stable --no-sandbox --remote-debugging-port=9222

# verify that I can reach the debugging server
$ curl 127.0.0.1:9222
curl: (7) Failed to connect to localhost port 9222: Connection refused

在容器外部(OSX 10.12.6),相同的过程可以正常工作:

# start chrome in debug mode
$ chrome --no-sandbox --remote-debugging-port=9222

# verify that I can reach the debugging server
$ curl localhost:9222
curl localhost:9222
<html>
<head>
<title>Inspectable pages</title>
...

必须有一些我失踪的东西,因为即使环境不同,它们似乎是相同的工作流程。

有人可以说明这里发生了什么吗?

::使用更多调试信息进行更新::

使用--enable-logging --v=1标志运行命令,我得到这些日志[没有一个看起来很了不起]:

[64:64:0118/111557.689426:VERBOSE1:breakpad_linux.cc(1980)] Breakpad disabled
[72:72:0118/111557.718821:VERBOSE1:zygote_main_linux.cc(594)] ZygoteMain: initializing 2 fork delegates
[72:72:0118/111557.719320:VERBOSE1:nacl_fork_delegate_linux.cc(146)] NaClForkDelegate::Init()
[72:72:0118/111557.724777:VERBOSE1:nacl_fork_delegate_linux.cc(146)] NaClForkDelegate::Init()
[72:72:0118/111557.728735:VERBOSE1:zygote_main_linux.cc(362)] Unable to load plugin internal-not-yet-present internal-not-yet-present: cannot open shared object file: No such file or directory
[72:72:0118/111557.729441:INFO:cpu_info.cc(50)] Available number of cores: 4
[64:64:0118/111557.731729:WARNING:browser_main_loop.cc(297)] Gtk: cannot open display:

运行netstat也不显示任何内容:

$ netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

1 个答案:

答案 0 :(得分:-1)

事实证明,在没有--headless标志的情况下,我所做的事情已经完成。

# start chrome in debug mode
$ google-chrome-stable --no-sandbox --remote-debugging-port=9222 --headless

# debugging server works as expected
$ curl 127.0.0.1:9222
<html>
<head>
<title>Inspectable pages</title>
...