windows - Windows docker 容器上的 Chrome 无法正常工作

标签 windows google-chrome docker angular-cli chocolatey

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

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

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

此外,我正在使用 chocolatey 来安装包。

这是我缩小的 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 的一个模块。

完整错误:

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)

最佳答案

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

事实证明 - 问题出在字体上。是的去图大声笑。

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

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

要求的字体:

  • 宋体
  • 安慰剂
  • 时代新罗马

关于windows - Windows docker 容器上的 Chrome 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52948655/

相关文章:

windows - 用于将每个第 n 个文件从 folder1 复制到 folder2 的批处理文件?

css - 我需要将所有前缀添加到 chrome 桌面应用程序吗?

r - 防止重复安装软件包,或在R中预先安装软件包

c# - 如何以编程方式找出 JRE 网络设置?

python - 写入文件时出现 IOError

c - XP 的 ZwQueryKey 与 KeyNameInformation 替代方案?

css - 谷歌浏览器 css 问题

html - 额外填充仅在 Chrome 中

amazon-web-services - 为特定路径设置 Ingress-Nginx 速率限制 rps

docker - Hyperledger Indy 数据未安装在 Kubernetes 卷目录中