Docker:使用 dockerfile 在 Windows 容器上安装 chrome

M.E*_*Eva 4 docker dockerfile docker-image docker-container docker-for-windows

我正在尝试在我的 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/*
Run Code Online (Sandbox Code Playgroud)

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

'apt-get' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

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

谢谢。

Joe*_*aly 7

这是我用来将 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
Run Code Online (Sandbox Code Playgroud)

另一条可能的路线。将所有安装程序复制到 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"]
Run Code Online (Sandbox Code Playgroud)

希望这有帮助...希望这有帮助