Windows 2019 Docker镜像中Microsoft Edge安装失败求助
问题背景
在标签为4.8-windowsservercore-ltsc2019的Windows Server 2019 Docker Jenkins代理容器中,通过Chocolatey安装Microsoft Edge用于Selenium前端测试时失败,返回错误码1603。Chrome可正常完成安装,Firefox安装耗时极久;相同操作在Windows 2019服务器VM中可正常执行,近两个月出现该故障。
关键错误日志
PS C:\Program Files (x86)> choco install microsoft-edge -y Chocolatey v1.3.1 Installing the following packages: microsoft-edge By installing, you accept licenses for the packages. Progress: Downloading microsoft-edge 112.0.1722.48... 100% microsoft-edge v112.0.1722.48 [Approved] microsoft-edge package files install completed. Performing other installation steps. File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded. Hashes match. Hashes match. Installing microsoft-edge... WARNING: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments=\"'/l*v c:\microsoft-edge_msi_install.log'\"'. Then search the MSI Log for \"Return Value 3\" and look above that for the error. ERROR: Running [\"C:\\Windows\\System32\\msiexec.exe\" /i \"C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\chocolatey\\microsoft-edge\\112.0.1722.48\\MicrosoftEdgeEnterpriseX64.msi\" /qn /norestart /l*v \"C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\chocolatey\\microsoft-edge.112.0.1722.48.MsiInstall.log\" ] was not successful. Exit code was '1603'. The install of microsoft-edge was NOT successful.
安装脚本
function install-Browsers(){ echo "Download/Install Firefox and Google Chrome" # Install packages $chocoPackages = "Firefox", "GoogleChrome","microsoft-edge" foreach ($package in $chocoPackages) { Write-Host "Installing Package: $package" -ForegroundColor Cyan choco install -y $package --no-progress } }
解决方案
1. 适配Server Core环境,添加Edge安装参数
Windows Server Core缺少桌面环境组件,需指定最小化安装参数避免依赖冲突,同时强制清理残留:
choco install microsoft-edge -y --no-progress --install-arguments="/qn INSTALLLEVEL=1 REINSTALL=ALL REINSTALLMODE=amus"
INSTALLLEVEL=1:仅安装Edge核心功能,跳过桌面UI依赖组件REINSTALL=ALL+REINSTALLMODE=amus:强制覆盖旧版本残留的文件/注册表项,解决因残留导致的1603错误
2. 升级Chocolatey并清理缓存
当前使用的Chocolatey 1.3.1版本较旧,对新版Edge MSI兼容性不足:
# 升级Chocolatey choco upgrade chocolatey -y # 清理缓存,避免损坏安装包残留 choco clean all -y
完成后重新执行安装命令。
3. 跳过Choco封装,手动安装Edge企业版MSI
若Choco包的封装逻辑不兼容Server Core,可直接下载官方MSI手动安装:
# 下载最新Edge企业版X64 MSI(替换为官方最新链接) Invoke-WebRequest -Uri "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/latest/MicrosoftEdgeEnterpriseX64.msi" -OutFile "$env:TEMP\MicrosoftEdgeEnterpriseX64.msi" # 执行最小化安装 msiexec.exe /i "$env:TEMP\MicrosoftEdgeEnterpriseX64.msi" /qn INSTALLLEVEL=1 /norestart /l*v "$env:TEMP\edge_install.log"
4. 处理容器内的挂起重启请求
Docker容器可能存在未处理的重启标记,导致MSI安装失败:
# 检查是否有挂起重启请求 $pendingReboot = $false if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ErrorAction SilentlyContinue) { $pendingReboot = $true } if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue) { $pendingReboot = $true } # 若存在则重置容器系统状态 if ($pendingReboot) { Restart-Computer -Force -Wait }
注意:容器需启动时配置--privileged权限才能执行重启操作。
5. 更换Edge包版本或安装Insider版本
尝试安装较新的稳定版Edge或Insider版本,规避旧包的兼容性问题:
# 安装最新稳定版(替换为实际版本号) choco install microsoft-edge --version=120.0.2210.91 -y --no-progress # 或安装Edge Insider版本 choco install microsoft-edge-insider -y --no-progress
内容的提问来源于stack exchange,提问作者Param J
相关产品推荐
相关产品推荐

