Windows docker 容器上的 Chrome 无法正常工作 [英] Chrome on Windows docker container is not working

查看:54
本文介绍了Windows docker 容器上的 Chrome 无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 docker 容器上运行 Google Chrome.这个 docker 容器基于 microsoft/windowsservercore:ltsc2016.我想使用 docker 容器来构建一个 AngularCLI-App.因此,我需要在 Google Chrome 中运行我的测试(带有:– headless flag).

I'm trying to run Google Chrome on a docker container. This docker container is based on the microsoft/windowsservercore:ltsc2016. I want to use the docker container to build an AngularCLI-App. Therefore, I need to run my tests in Google Chrome (with: – headless flag).

使用 Chrome 运行测试对我来说是一个新功能,因为我的 Angular-Apps 不是基于 Angular CLI 结构并且测试是使用 PhantomJS 执行的.

Running tests with Chrome is a new feature for me, because my Angular-Apps are not based on an Angular CLI structure and the tests were executed with PhantomJS.

我已经更新了我的整个 Angular 项目以适应 AngularCLI 结构,因为我希望它们基于标准的 Angular 方式.所以我正在尝试使用 Chrome 而不是 PhantomJS.

I have updated my whole Angular-Project to fit in an AngularCLI-structure, because I want them to base on a standard Angular way. So I'm trying to use Chrome instead of PhantomJS.

此外,我使用 Chocolatey 来安装软件包.

Moreover, I'm using chocolatey to install packages.

这是我缩小的 dockerfile:

Here is my minified dockerfile:

FROM microsoft/windowsservercore:ltsc2016

RUN choco install -y googlechrome && \
    choco install -y nodejs --version 8.11.3

# npm konfiguration um den dvelop-npm ProGet feed nutzen zu können
RUN npm install -g @angular/cli

我可以使用完整的 dockerfile 构建 AngularApp,但我的测试不起作用.启动 Chrome 时出现错误,提示在 chrome.dll 中找不到 Chrome 的一个模块.

I'm able to build the AngularApp with my full dockerfile, but my tests aren't working. During starting Chrome there appears an error, which says that one module of Chrome could not be found inside the chrome.dll.

完全错误:

Project name: dapi-provider
22 10 2018 11:16:09.393:INFO [karma]: Karma v3.0.0 server started at http://0.0.0.0:9876/
22 10 2018 11:16:09.396:INFO [launcher]: Launching browser ChromeHeadlessNoSandbox with unlimited concurrency
22 10 2018 11:16:09.410:INFO [launcher]: Starting browser Chrome
22 10 2018 11:16:10.238:ERROR [launcher]: Cannot start Chrome
        [1022/111609.595:ERROR:main_dll_loader_win.cc(134)] Failed to load Chrome DLL from C:\Program Files (x86)\Google\Chrome\Application\70.0.3538.67\chrome.dll: The specified module could not be found. (0x7E)

推荐答案

我知道这是一个迟到的回应 - 但几周前我自己也在同一条船上.

I know this is a late response - but I was in the same boat myself a couple of weeks ago.

事实证明 - 问题是字体.是的,去图哈哈.

It turns out - the issue is Fonts. Yeah go figure lol.

ServerCore 只包含一种字体,而不包含谷歌浏览器渲染 UI 所需的字体.

ServerCore only contains one font, and not the fonts required by google chrome to render the UI.

我在这里为您整理了所需的字体,并展示了如何在 Windows 容器中提取和安装:https://github.com/prom3theu5/ServerCoreFonts

I've put together the required fonts here for you, and shown how to extract and install in the windows container: https://github.com/prom3theu5/ServerCoreFonts

所需字体:

  • 宋体
  • 控制台
  • 时代新罗马

这篇关于Windows docker 容器上的 Chrome 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆