Google chrome 镀铬无头罐';在docker compose中无法访问网络上的URL
问题的简要描述如下:Google chrome 镀铬无头罐';在docker compose中无法访问网络上的URL,google-chrome,docker,docker-compose,google-chrome-headless,Google Chrome,Docker,Docker Compose,Google Chrome Headless,问题的简要描述如下: 我有docker compose设置和两个服务:app和test 我可以在test中获得chrome headless以访问公共URL 我可以让test成功卷曲到app 但是我无法让测试加载docker上用chrome headless组成网络的URL 我有一个docker compose文件,其中包含两个服务,如下所示: version: '3' services: app: build: context: . dock
- 我有docker compose设置和两个服务:
和app
test
- 我可以在
中获得chrome headless以访问公共URLtest
- 我可以让
成功卷曲到test
app
- 但是我无法让
测试
加载docker上用chrome headless组成网络的URL
version: '3'
services:
app:
build:
context: .
dockerfile: App.Dockerfile
ports:
- 5000:5000
restart: always
test:
build:
context: .
dockerfile: Chrome.Dockerfile
depends_on:
- app
Chrome.Dockerfile
安装Chrome的方式如下:
FROM node:8-slim
RUN apt-get update --fix-missing && apt-get -y upgrade
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-unstable --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /src/*.deb
ADD entrypoint .
CMD ./entrypoint
入口点脚本如下所示:
#!/bin/bash
echo ""
echo "Demonstrates that curl can access the host app on port 5000..."
echo ""
curl http://app:5000/
echo ""
echo "Demonstrates that chrome headless is working..."
echo ""
google-chrome \
--headless \
--disable-gpu \
--no-sandbox \
--dump-dom \
http://example.com/
echo ""
echo "Demonstrates that chrome headless is not successful with app:500"
echo
google-chrome \
--headless \
--disable-gpu \
--no-sandbox \
--dump-dom \
--enable-logging --v=10000 \
http://app:5000/
Starting experiment_app_1 ... done
Demonstrates that curl can access the host app on port 5000...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A page</title>
</head>
<body>
<h1>A heading</h1>
</body>
</html>
Demonstrates that chrome headless is working...
[0303/074652.347092:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Fontconfig warning: "/etc/fonts/fonts.conf", line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf
<!DOCTYPE html>
<html>
...all the html from example.com
</html>
Demonstrates that chrome headless is not successful with app:5000
[0303/074652.598662:VERBOSE1:zygote_main_linux.cc(336)] ZygoteMain: initializing 0 fork delegates
[0303/074652.599327:INFO:cpu_info.cc(50)] Available number of cores: 4
[0303/074652.603129:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
[0303/074652.603580:VERBOSE1:pulse_stubs.cc(683)] dlopen(libpulse.so.0) failed, dlerror() says:
libpulse.so.0: cannot open shared object file: No such file or directory
[0303/074652.603681:VERBOSE1:pulse_util.cc(106)] Failed on loading the Pulse library and symbols
[0303/074652.603843:VERBOSE1:webrtc_internals.cc(114)] Could not get the download directory.
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
[0303/074652.609098:VERBOSE1:breakpad_linux.cc(1997)] Non Browser crash dumping enabled for: renderer
Fontconfig warning: "/etc/fonts/fonts.conf", line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf
[0303/074652.708611:VERBOSE1:multi_log_ct_verifier.cc(75)] Adding CT log: Google 'Aviator' log
...more logs
[0303/074652.708843:VERBOSE1:multi_log_ct_verifier.cc(75)] Adding CT log: Certly.IO log
[0303/074652.708853:VERBOSE1:proxy_service.cc(955)] PAC support disabled because there is no system implementation
[0303/074652.713231:VERBOSE1:network_delegate.cc(30)] NetworkDelegate::NotifyBeforeURLRequest: http://app:5000/
[0303/074652.715447:VERBOSE1:network_delegate.cc(30)] NetworkDelegate::NotifyBeforeURLRequest: https://app:5000/
[0303/074652.719183:ERROR:ssl_client_socket_impl.cc(1098)] handshake failed; returned -1, SSL error code 1, net_error -107
[0303/074652.738050:VERBOSE2:ThreadState.cpp(533)] [state:0x55a5e7840fc0] ScheduleGCIfNeeded
...
[0303/074652.742949:VERBOSE1:V8ContextSnapshot.cpp(140)] A context is created from snapshot for main world
[0303/074652.746847:VERBOSE2:ThreadState.cpp(496)] [state:0x55a5e7840fc0] SchedulePageNavigationGCIfNeeded: estimatedRemovalRatio=0.75
[0303/074652.749427:VERBOSE1:V8ContextSnapshot.cpp(140)] A context is created from snapshot for main world
[0303/074652.763112:VERBOSE1:sandbox_ipc_linux.cc(131)] SandboxIPCHandler stopping.
<html><head></head><body></body></html>
输出如下所示:
#!/bin/bash
echo ""
echo "Demonstrates that curl can access the host app on port 5000..."
echo ""
curl http://app:5000/
echo ""
echo "Demonstrates that chrome headless is working..."
echo ""
google-chrome \
--headless \
--disable-gpu \
--no-sandbox \
--dump-dom \
http://example.com/
echo ""
echo "Demonstrates that chrome headless is not successful with app:500"
echo
google-chrome \
--headless \
--disable-gpu \
--no-sandbox \
--dump-dom \
--enable-logging --v=10000 \
http://app:5000/
Starting experiment_app_1 ... done
Demonstrates that curl can access the host app on port 5000...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A page</title>
</head>
<body>
<h1>A heading</h1>
</body>
</html>
Demonstrates that chrome headless is working...
[0303/074652.347092:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Fontconfig warning: "/etc/fonts/fonts.conf", line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf
<!DOCTYPE html>
<html>
...all the html from example.com
</html>
Demonstrates that chrome headless is not successful with app:5000
[0303/074652.598662:VERBOSE1:zygote_main_linux.cc(336)] ZygoteMain: initializing 0 fork delegates
[0303/074652.599327:INFO:cpu_info.cc(50)] Available number of cores: 4
[0303/074652.603129:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
[0303/074652.603580:VERBOSE1:pulse_stubs.cc(683)] dlopen(libpulse.so.0) failed, dlerror() says:
libpulse.so.0: cannot open shared object file: No such file or directory
[0303/074652.603681:VERBOSE1:pulse_util.cc(106)] Failed on loading the Pulse library and symbols
[0303/074652.603843:VERBOSE1:webrtc_internals.cc(114)] Could not get the download directory.
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
[0303/074652.609098:VERBOSE1:breakpad_linux.cc(1997)] Non Browser crash dumping enabled for: renderer
Fontconfig warning: "/etc/fonts/fonts.conf", line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf
[0303/074652.708611:VERBOSE1:multi_log_ct_verifier.cc(75)] Adding CT log: Google 'Aviator' log
...more logs
[0303/074652.708843:VERBOSE1:multi_log_ct_verifier.cc(75)] Adding CT log: Certly.IO log
[0303/074652.708853:VERBOSE1:proxy_service.cc(955)] PAC support disabled because there is no system implementation
[0303/074652.713231:VERBOSE1:network_delegate.cc(30)] NetworkDelegate::NotifyBeforeURLRequest: http://app:5000/
[0303/074652.715447:VERBOSE1:network_delegate.cc(30)] NetworkDelegate::NotifyBeforeURLRequest: https://app:5000/
[0303/074652.719183:ERROR:ssl_client_socket_impl.cc(1098)] handshake failed; returned -1, SSL error code 1, net_error -107
[0303/074652.738050:VERBOSE2:ThreadState.cpp(533)] [state:0x55a5e7840fc0] ScheduleGCIfNeeded
...
[0303/074652.742949:VERBOSE1:V8ContextSnapshot.cpp(140)] A context is created from snapshot for main world
[0303/074652.746847:VERBOSE2:ThreadState.cpp(496)] [state:0x55a5e7840fc0] SchedulePageNavigationGCIfNeeded: estimatedRemovalRatio=0.75
[0303/074652.749427:VERBOSE1:V8ContextSnapshot.cpp(140)] A context is created from snapshot for main world
[0303/074652.763112:VERBOSE1:sandbox_ipc_linux.cc(131)] SandboxIPCHandler stopping.
<html><head></head><body></body></html>
开始实验\u应用程序\u 1。。。完成
演示curl可以访问端口5000上的主机应用程序。。。
一页
标题
表明镀铬无头灯正在工作。。。
[0303/074652.347092:错误:gpu_进程_传输_工厂.cc(1007)]丢失UI共享上下文。
libudev:udev\u在/dev:操作不允许时将\u devtmpfs:name\u添加到\u handle\u
Fontconfig警告:“/etc/fonts/fonts.conf”,第146行:blank不再生效。请将其从fonts.conf中删除
…所有来自example.com的html
证明chrome headless在app:5000上不成功
[0303/074652.598662:VERBOSE1:zyote_main_linux.cc(336)]zyotemain:初始化0个fork委托
[0303/074652.599327:信息:cpu_INFO.cc(50)]可用内核数:4
[0303/074652.603129:错误:gpu_进程_传输_工厂.cc(1007)]丢失UI共享上下文。
[0303/074652.603580:VERBOSE1:pulse_stubs.cc(683)]dlopen(libpulse.so.0)失败,dlerror()表示:
libpulse.so.0:无法打开共享对象文件:没有此类文件或目录
[0303/074652.603681:VERBOSE1:pulse_util.cc(106)]加载脉冲库和符号时失败
[0303/074652.603843:VERBOSE1:webrtc_internals.cc(114)]无法获取下载目录。
libudev:udev\u在/dev:操作不允许时将\u devtmpfs:name\u添加到\u handle\u
[0303/074652.609098:VERBOSE1:breakpad_linux.cc(1997)]为:渲染器启用非浏览器崩溃转储
Fontconfig警告:“/etc/fonts/fonts.conf”,第146行:blank不再生效。请将其从fonts.conf中删除
[0303/074652.708611:VERBOSE1:multi_log_ct_verifier.cc(75)]添加ct日志:谷歌“飞行员”日志
…更多日志
[0303/074652.708843:VERBOSE1:multi_log_ct_verifier.cc(75)]添加ct log:Certly.IO log
[0303/074652.708853:VERBOSE1:proxy_service.cc(955)]由于没有系统实现,PAC支持被禁用
[0303/074652.713231:VERBOSE1:network_delegate.cc(30)]NetworkDelegate::NotifyBeforeURLRequest:http://app:5000/
[0303/074652.715447:VERBOSE1:network_delegate.cc(30)]NetworkDelegate::NotifyBeforeURLRequest:https://app:5000/
[0303/074652.719183:错误:ssl_客户端_套接字_impl.cc(1098)]握手失败;返回-1,SSL错误代码1,网络错误-107
[0303/074652.738050:VERBOSE2:ThreadState.cpp(533)][状态:0x55a5e7840fc0]计划如果需要
...
[0303/074652.742949:VERBOSE1:V8ContextSnapshot.cpp(140)]从主世界的快照创建上下文
[0303/074652.746847:VERBOSE2:ThreadState.cpp(496)][状态:0x55a5e7840fc0]计划页面导航GCIfNeeded:estimatedRemovalRatio=0.75
[0303/074652.749427:VERBOSE1:V8ContextSnapshot.cpp(140)]从主世界的快照创建上下文
[0303/074652.763112:VERBOSE1:sandbox_ipc_linux.cc(131)]sandboxipchHandler正在停止。
因此,如果curl工作,而chrome headless工作,为什么chrome headless不能加载http://app:5000
URL
下面是一份完整的回购协议,它说明了问题:
注1:libudev:udev\u在/dev:Operation not allowed
上有\u devtmpfs:name\u to \u handle\u可能是相关的,我可以用cap add sys\u admin等几种方法解决这个问题,但似乎没有任何效果
注2:关于错误:ssl\u client\u socket\u impl
,该应用程序没有公开ssl,因此这是意料之中的(我想)。我还不能确切说明原因,但将服务名称从应用程序更改为应用程序
以外的其他名称可以修复它:
版本:“3”
服务:
其他:
建造:
上下文:。
dockerfile:App.dockerfile
端口:
- 5000:5000
重新启动:始终
测试:
建造:
上下文:。
dockerfile:Chrome.dockerfile
取决于:
-其他
显然,Chrome(至少以我的设置方式)处理http://app:5000/
与http://other:5000