如何使用 Windows Docker 安装安装文件.msi

时间:2021-01-18 15:25:10

标签: windows file installation containers windows-installer

我必须在 Windows 10 Pro(带有 Hyper-V)上执行安装 POL-1.0.msi 文件(位于 Dockerfile 目录中)并运行 Windows Docker 容器。 Dockerfile 是:

FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Start-Process -Wait -PassThru -FilePath C:\windows\SysWOW64\msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
#or
RUN Start-Process -Wait -PassThru -FilePath C:\windows\system32\msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
#or
RUN Start-Process -Wait -PassThru -FilePath msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'

Dockerfile 的构建是:

PS D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2> docker build -t pol_img .
Sending build context to Docker daemon  803.4MB
Step 1/3 : FROM mcr.microsoft.com/windows/servercore:ltsc2019
 ---> 5e0078d88ebd
Step 2/3 : SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
 ---> Using cache
 ---> 60482d7efc63
Step 3/3 : RUN Start-Process -Wait -PassThru -FilePath C:\windows\SysWOW64\msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
#or
Step 3/3 : RUN Start-Process -Wait -PassThru -FilePath C:\windows\System32\msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
#or
Step 3/3 : RUN Start-Process -Wait -PassThru -FilePath msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
 ---> Running in 15bb4f4e440f

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    185      11     1864       8952       0.02   1816   1 msiexec


Removing intermediate container 15bb4f4e440f
 ---> cdff1d0573f4
Successfully built cdff1d0573f4
Successfully tagged pol_img:latest

创建的镜像的运行是:

PS D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2> docker run --name pol pol_img:latest
Microsoft Windows [Version 10.0.17763.1697]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>
PS D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2>

运行镜像'pol_img:latest'后,安装目录'C:\Users\Alex\AppData\Local\POL'为空,'C:'日志文件'pol.log'没有存在。 我知道在 Windows 容器上运行 GUI 是不可能的。所以,我执行“安静”安装。在 Dockerfile 中,它是:

RUN Start-Process -Wait -PassThru -FilePath C:\windows\SysWOW64\msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* c:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
#or
RUN Start-Process -Wait -PassThru -FilePath C:\windows\system32\msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* C:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'
#or
RUN Start-Process -Wait -PassThru -FilePath msiexec.exe -ArgumentList '/a  C:\\POL-1.0.msi /quiet /q /l* C:\\pol.log  INSTALL_SERIALNUM=1234 ALLUSERS=1'

当我直接运行'POL.msi'文件的'安静'安装

PS D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2> msiexec /i POL-1.0.msi /quiet /L*V pol.log
PS D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2>

通过安装文件“POL.exe”、“POL.ico”和目录“app”、“runtime”,应用程序安装在“C:\Users\Alex\AppData\Local\POL”目录中。 logfile pol.log 内容的大写为:

=== Verbose logging started: 18/01/2021  16:40:37  Build type: SHIP UNICODE 
5.00.10011.00  Calling process: C:\WINDOWS\SysWOW64\msiexec.exe ===
MSI (c) (80:1C) [16:40:37:304]: Resetting cached policy values
MSI (c) (80:1C) [16:40:37:304]: Machine policy value 'Debug' is 0
MSI (c) (80:1C) [16:40:37:304]: ******* RunEngine:
           ******* Product: POL-1.0.msi
           ******* Action: 
           ******* CommandLine: **********
MSI (c) (80:1C) [16:40:37:304]: Client-side and UI is none or basic: Running entire install on the server.
MSI (c) (80:1C) [16:40:37:304]: Grabbed execution mutex.
MSI (c) (80:1C) [16:40:37:316]: Cloaking enabled.
MSI (c) (80:1C) [16:40:37:316]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (80:1C) [16:40:37:319]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (4C:F8) [16:40:37:328]: Running installation inside multi-package transaction D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2\POL-1.0.msi
MSI (s) (4C:F8) [16:40:37:329]: Grabbed execution mutex.
MSI (s) (4C:44) [16:40:37:333]: Resetting cached policy values
MSI (s) (4C:44) [16:40:37:333]: Machine policy value 'Debug' is 0
MSI (s) (4C:44) [16:40:37:333]: ******* RunEngine:
           ******* Product: D:\Work\POL\DockerInstaller\Docker\Pol_test_gradle2\POL-1.0.msi
           ******* Action: 
           ******* CommandLine: **********

我从 https://voloda.bazilisek.net/2017/12/how-to-create-docker-build-agent-image-with-sdk-installed-from-msi/ 站点获取了我的 Dockerfile 的基础。 我知道 Docker 在构建映像并运行它的过程中,会在内部创建文件和目录,在这种情况下可以使用此 Dockerfile。因此,可能是因为安装文件的安装没有在容器外执行,并且容器外的安装目录保持为空。如果可能是原因 - 使用“mount”和“volume”是否可以解决容器外的安装问题?如果是 - 如何?

0 个答案:

没有答案
相关问题