可执行文件不产生任何输出,在 Windows Docker 容器中默默失败

可执行文件不产生任何输出,在 Windows Docker 容器中默默失败

集装箱信息:

Windows Server 2019 Standard image running on Windows Server 2019 Standard

我有一个可执行文件(https://github.com/levi-blodgett/HpToolsLauncher/blob/main/HpToolsLauncher.exe,Jenkins 内部提供的插件然后运行可执行文件),无论我做什么,我都无法获得任何输出,如果你在任何其他我尝试过的系统上直接调用 .exe(Windows 10 和 Windows Server 2019 系统),这是输出:

C:\Users\LeviBlodgett\Documents\dependencies>.\HpToolsLauncher.exe   
"Started..."
Micro Focus Automation Tools Command Line Executer
Usage: HpToolsLauncher.exe  -paramfile <a file in key=value format>   -encoding ASCII | UTF-7 |
UTF-8 | UTF-16
...etc...

此 .exe 在从任何目录中的命令行调用时都应产生此输出,并且权限良好。

但是,当我在docker容器内运行时(使用“docker exec -it <container_id> powershell连接后):

PS C:\dependencies> .\HpToolsLauncher.exe
PS C:\dependencies> 

此.exe 无需设置即可运行,它是完全相同的文件,我已经检查过:

    .NET version
    Permissions
    Security
    Dependencies (possible I missed something, was using https://github.com/lucasg/Dependencies)
    Running on cmd and powershell, as user and as admin
    https://stackoverflow.com/questions/60823381/unable-to-run-32-bit-exe-in-windows-containers (tested the executable on a new image with no config, using the 02.20.20 release of MS core and I still get no output.

我可以从中获取输出或者查看容器中进程的 .exe 文件示例:

notepad.exe
git.exe
python.exe

Dockerfile:

FROM jenkins/jenkins:jdk11-hotspot-windowsservercore-2019

# set paths
RUN $env:PATH = $env:PATH + ';C:\Python\;C:\Python\lib\site-packages\;C:\Python\Scripts\;C:\Users\jenkins\AppData\Roaming\Python\Python310\Scripts;C:\MinGit\cmd\;C:\MinGit\cmd'; \
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH;

# download, install mingit
RUN Invoke-WebRequest 'https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.2/MinGit-2.12.2.2-64-bit.zip' -OutFile MinGit.zip; \
Expand-Archive c:\MinGit.zip -DestinationPath c:\MinGit;

# download, install Python 3
RUN Invoke-WebRequest 'https://www.python.org/ftp/python/3.10.6/python-3.10.6-embed-amd64.zip' -OutFile python.zip; \
Expand-Archive c:\python.zip -DestinationPath c:\Python;

# download, install pip
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; \
python get-pip.py ; \
Add-Content -Path C:\Python\python310._pth -Exclude help* -Value 'lib\site-packages';

# download, install pip packages
RUN pip install imap_tools requests;

# download, set shell, then install visualsvn
RUN Invoke-WebRequest 'https://www.visualsvn.com/files/VisualSVN-Server-5.0.3-x64.msi' -OutFile svn.msi;
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"];
RUN Start-Process 'svn.msi' '/qn /norestart /L*V "svn.log"' -PassThru | Wait-Process;

# download, install Dependencies.exe and HpToolsLauncher.exe
COPY ./dependencies C:\\dependencies

编辑/更新:

我尝试将丢失的 DLL(GdiPlus.dll 的 x86 版本)添加到 C:\Windows\SysWOW64\,然后注册,但仍然不起作用:

PS C:\> C:\Windows\SysWOW64\regsvr32 /s /i “C:\Windows\SysWOW64\GdiPlus.dll”
PS C:\> C:\dependencies\HpToolsLauncher.exe
PS C:\> $?
False
PS C:\> $LASTEXITCODE
-1073741511
PS C:\> 

然而值得注意的是,当我运行时:

.\Dependencies.exe -json -knowndll .\HpToolsLauncher.exe

尽管我注册了它,但它并没有在 x86 下显示 gdiplus.dll,所以也许我没有为 docker 正确添加它。

答案1

这个问题在错误报告中进行了讨论
使用基于 Windows 的 docker 镜像时无法加载 DLL“gdiplus.dll”#1098

解释是,您使用的基准图像不包含System.Drawing.Common该文件gdiplus.dll

您需要一个使用 ServerCore 映像的容器(显然您已经这样做了)并添加 dotnet core 运行时和 aspnet core 运行时。

这是一个 例子 为了简单起见,使用 chocolatey 来安装它们:

#
# This base image is to host dotnet core asp apps on servercore images 
# to better support things like GDI+ image manipulation or COM
#

FROM  mcr.microsoft.com/windows/servercore:1803
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

WORKDIR /app
RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
    choco install dotnetcore-runtime --version 2.2.7 -y; \
    choco install aspnetcore-runtimepackagestore --version 2.2.7 -y

ENV ASPNETCORE_URLS http://*:80
EXPOSE 80

使用与您的基础图像相匹配的 dotnet 版本。

答案2

发布以防万一会帮助到别人,对我来说,对主机进行 windows 更新解决了这个问题(不是 op 的同一个 exe,而是另一个)

相关内容