【问题标题】:Docker returning exit code 3221225781 installing vc_redist.x64.exeDocker 返回退出代码 3221225781 安装 vc_redist.x64.exe
【发布时间】:2020-06-06 11:21:12
【问题描述】:

我已经看到很多关于退出代码“3221225781”的问题,以响应 docker RUN,但我仍然无法找到答案。考虑这个 dockerfile:

FROM mcr.microsoft.com/dotnet/core/runtime:3.1
WORKDIR /app
ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.x64.exe
RUN VC_redist.x64.exe /install /quiet /norestart /log vc_redist.log

运行时,我得到以下输出:

C:\test>docker image build -t exitcodetest:1.0 .
Sending build context to Docker daemon  113.2MB
Step 1/4 : FROM mcr.microsoft.com/dotnet/core/runtime:3.1
 ---> 3be5e0b7f3a5
Step 2/4 : WORKDIR /app
 ---> Using cache
 ---> 4508bead23e2
Step 3/4 : ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.x64.exe
Downloading [==================================================>]  15.06MB/15.06MB

 ---> 37322d63b677
Step 4/4 : RUN VC_redist.x64.exe /install /quiet /norestart /log vc_redist.log
 ---> Running in c57b67befa33
The command 'cmd /S /C VC_redist.x64.exe /install /quiet /norestart /log vc_redist.log' returned a non-zero code: 3221225781

为什么我会收到此退出代码?这是什么意思?我还确认没有写入 vc_redist.log。

有人知道我可以做些什么来让它工作吗?

我应该补充一点,当我在本地机器上运行该命令时,它会起作用,并返回零 %ERRORLEVEL%。

谢谢!

【问题讨论】:

    标签: docker dockerfile


    【解决方案1】:

    我想我想通了。看起来图像“mcr.microsoft.com/dotnet/core/runtime:3.1.1”只是一个“层”,它只包含安装运行时所需的配方,但不包含底层操作系统规范(请如果那是错误的,请纠正我)。因此,我首先需要提供操作系统并安装到该操作系统,然后应用 .NET Core 运行时。这似乎有效:

    FROM mcr.microsoft.com/windows/servercore:ltsc2019
    WORKDIR /app
    ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.x64.exe
    RUN VC_redist.x64.exe /install /quiet /norestart /log vc_redist.log
    FROM mcr.microsoft.com/dotnet/core/runtime:3.1.1
    

    【讨论】:

    • 你能分享你完整的 Dockerfile 吗?我正在尝试对 .net core 3.1.2 做同样的事情。谢谢
    • 我在新答案中为您添加了我的 dockerfile 的非应用程序特定部分。
    • 非常感谢 - 这很有帮助。基于此,我设法使用 C++ x86 Redistributable 和最新的 .NET Core SDK (3.1.2) 构建了一个基于 servercore:ltsc2019 的图像。我的使用 dllimport 访问包装在 x86 C++ DLL 中的功能的 Web API 似乎工作正常。我可以从容器内卷曲并得到我期望的响应。出于某种原因,我无法从容器外部访问 API。您是否遇到过类似的连接问题?
    • 不,我的 docker 只进行计算,不接收任何传入指令。您是否在 dockerfile 中公开了端口? docs.docker.com/engine/reference/builder/#expose 如果是这样,也许看看 ASP.NET Core dockerfile 看看他们是否打开了防火墙或类似的东西。祝你好运。
    【解决方案2】:

    @ProfNimrod 我需要使用具有 Azure 可以使用的操作系统的映像,而不仅仅是一个带有 .NET 的层。所以我从这张图片开始,基本上复制了微软安装 .NET 的方式。我需要这样做,因为我的应用程序还在操作系统上安装了一些自定义驱动程序。可能有更好的方法,但我还没有看到。

    # escape=`
    
    # Use an Azure-supported image.
    FROM mcr.microsoft.com/windows:1809-amd64
    
    # Use PowerShell for the command shell because we will use it to install the .NET runtime
    SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
    
    
    # =================================================================
    # Install .NET Core Runtime
    # =================================================================
    
    # Retrieve and install the .NET Core Runtime
    RUN $dotnet_archive_file = 'C:\Windows\Temp\dotnet-runtime-3.1.2-win-x64.zip'; `
        $dotnet_archive_file_sha512 = '2986d9f04640115cfa1ec478ac20d8e5c0f3b57f1d4e379300dfbafe8d20ec775ea1987045d611a1b2d786de7e1981c57ef52824a9d8dda64e1570379187b23f'; `
        $dotnet_archive_url = 'https://dotnetcli.azureedge.net/dotnet/Runtime/3.1.2/dotnet-runtime-3.1.2-win-x64.zip'; `
        $dotnet_install_directory = 'C:\Program Files\dotnet'; `
        Invoke-WebRequest -OutFile $dotnet_archive_file $dotnet_archive_url; `
        if ((Get-FileHash $dotnet_archive_file -Algorithm sha512).Hash -ne $dotnet_archive_file_sha512) { `
            Write-Host \"CHECKSUM VERIFICATION FAILED: $dotnet_archive_url\"; `
            exit 1; `
        }; `
        Expand-Archive $dotnet_archive_file -DestinationPath $dotnet_install_directory; `
        Remove-Item -Force $dotnet_archive_file
    
    # These common .NET-specific environment variables should be specified
    ENV `
        # Configure web servers to bind to port 80 when present
        ASPNETCORE_URLS=http://+:80 `
        # Enable detection of running in a container
        DOTNET_RUNNING_IN_CONTAINER=true
    
    # Update the global %PATH% to complete the .NET installation
    # In order to set system PATH, ContainerAdministrator must be used
    USER ContainerAdministrator
    RUN $oldPath = [System.Environment]::GetEnvironmentVariable('path', [System.EnvironmentVariableTarget]::Machine); `
        $dotnet_install_directory = 'C:\Program Files\dotnet'; `
        $setx_process = Start-Process -FilePath 'setx.exe' -ArgumentList \"/M PATH \"\"$oldPath;$dotnet_install_directory\"\"\" -NoNewWindow -Wait -PassThru; `
        if ($setx_process.ExitCode -ne 0) { `
            Write-Host \"PROCESS FAILED: setx.exe (Exit Code: $($setx_process.ExitCode))\"; `
            exit 1; `
        }
    USER ContainerUser
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-07
      • 2017-02-23
      • 2021-04-02
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      • 2018-07-13
      相关资源
      最近更新 更多