【问题标题】:Docker: Install chrome on Windows container using dockerfileDocker:使用 dockerfile 在 Windows 容器上安装 chrome
【发布时间】:2019-04-12 09:16:27
【问题描述】:

我正在尝试在我的 Windows 容器上安装 Chrome。我用 dockerfile 创建了我的 docker 映像,我想使用这个 dockerfile 安装 chrome。我已经尝试使用以下命令

RUN apt-get update -qqy \
&& apt-get -qqy install \
xvfb \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

但我有一个错误(我认为这是因为我在 windows 容器上,这个命令仅适用于 unbutu 容器......):

'apt-get' is not recognized as an internal or external command,
operable program or batch file.

有没有办法在 windows 容器中安装 chrome?或者任何替换 'apt-get' 的命令?

谢谢。

【问题讨论】:

  • 你可以看看这里:chocolatey.org
  • 您好,感谢您的评论,我查看了 Chocolatey,可能找到了解决方案,这是我使用 Chocolatey 的代码摘录:RUN powershell -Command iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')); RUN choco install -y googlechrome 但我有一个错误最后:命令'cmd /S /C choco install -y googlechrome' returned a non-zero code: 4294967295
  • 你可以试试choco install googlechrome --ignore-checksums
  • 我能问一下您为什么要在 Windows 容器上安装 Chrome(或任何带有 GUI 的东西)吗?还是仅适用于 Chrome Headless?

标签: docker dockerfile docker-container docker-image docker-for-windows


【解决方案1】:

这是我用来将 headless chrome 安装到 aspnet 4.5 映像中的 dockerfile。享受吧。

# extending the `microsoft/aspnet` image.
FROM microsoft/aspnet

RUN echo 'pull down choco'
RUN powershell -Command Install-PackageProvider -name chocolatey -Force
RUN powershell -Command Set-PackageSource -Name chocolatey -Trusted

RUN powershell -Command Get-PackageSource

RUN echo 'install chrome via choco'
RUN powershell -Command Install-Package GoogleChrome -MinimumVersion 74

另一条可能的路线。将所有安装程序复制到 dockerfile 旁边的“安装程序目录”中。然后将它们复制进去并手动运行。

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
RUN mkdir installers 
COPY ./installers/ /installers
RUN ["c:/installers/ChromeStandaloneSetup64.exe", "/silent", "/install"]
RUN ["c:/installers/Firefox Setup 66.0.3.exe", "-ms"]

希望这会有所帮助... 希望这会有所帮助

【讨论】:

  • 谢谢乔。 -RequiredVersion 73(当前已过时)不适用于这种方法,因此不确定任何开关在此处是否重要。有办法安装特定版本吗?看起来chocolatey 总是安装msi(总是安装最新的)
  • 对于旧版本的 chrome,see instructions here。因此,在安装旧版本不太漂亮/容易之后,可能还需要禁用谷歌更新服务,例如 Get-Service gupdate* | Stop-Service
  • @SubjectiveReality - 使用 -MinimumVersion 73 -MaximumVersion 73 怎么样?我不能在这里测试,因为我们的代理目前正在炒我。
  • 我认为它不会按照chocolatey's install url for v73 上的注释工作... This package always installs the latest version of Google Chrome, regardless of the version specified in the package. Google does not officially offer older versions of Chrome for download.
  • 你可以找到 73 的安装程序,把它放到一个“侧目录”,然后把它推到你的镜像中吗?由于一些代理问题,我今天不得不这样做。 FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 运行 mkdir 安装程序 COPY ./installers/ /installers 运行 ["c:/installers/ChromeStandaloneSetup64.exe", "/silent", "/install" ] 运行 ["c:/installers/Firefox Setup 66.0.3.exe", "-ms"]
猜你喜欢
  • 1970-01-01
  • 2017-12-01
  • 1970-01-01
  • 2021-07-21
  • 2019-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多