Agendum
Agendum

Reputation: 2021

Docker returning exit code 3221225781 installing vc_redist.x64.exe

I have seen lots of questions about exit code '3221225781' in response to docker RUN, but I am unable to find an answer still. Consider this 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

When running this, I get the following output:

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

Why would I be getting this exit code? What does it mean? I also confirmed that a vc_redist.log is not being written.

Anybody know what I can do to get this to work?

I should add that the command works when I run it on my local machine, and returns a zero %ERRORLEVEL%.

Thanks!

Upvotes: 5

Views: 5506

Answers (3)

Jay
Jay

Reputation: 1411

The problem is that mcr.microsoft.com/dotnet/core/runtime:3.1 doesn't have support for 32-bit binaries. It's strange that the VC Runtime installer for x86_64 is itself a 32-bit binary, but here's proof:

❯ sigcheck .\VC_redist.x64.exe

Sigcheck v2.82 - File version and signature viewer
Copyright (C) 2004-2021 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\Users\jaysi\Downloads\VC_redist.x64.exe:
        Verified:       Signed
        Signing date:   6:48 PM 12/10/2021
        Publisher:      Microsoft Corporation
        Company:        Microsoft Corporation
        Description:    Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.29.30139
        Product:        Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.29.30139
        Prod version:   14.29.30139.0
        File version:   14.29.30139.0
        MachineType:    32-bit

You'll need to use a ServerCore (mcr.microsoft.com/windows/servercore) based image, or a full windows image (mcr.microsoft.com/windows).

The image that you were using is based on nanoserver. You can see for yourself at this page: https://hub.docker.com/_/microsoft-dotnet-runtime , which lists the tags as 3.1.23-nanoserver-ltsc2022, 3.1-nanoserver-ltsc2022, 3.1.23, 3.1. There don't seem to be any prebuilt images for 3.1 that use servercore, but there are for 5.0 (5.0.15-windowsservercore-ltsc2022, 5.0-windowsservercore-ltsc2022) and 6.0 (6.0.3-windowsservercore-ltsc2022, 6.0-windowsservercore-ltsc2022). If you really need 3.1, then the Dockerfile for how it was created is listed on the page above, but here's a link: https://github.com/dotnet/dotnet-docker/blob/b59aec0147eaf2468d116c1d1aa2577a33ee456c/src/runtime/3.1/nanoserver-ltsc2022/amd64/Dockerfile . You can change the nanoserver base image to servercore, and do whatever other setup you may need for your base image.

Upvotes: 1

Agendum
Agendum

Reputation: 2021

@ProfNimrod I needed to use an image which has an operating system that Azure could use, not just a layer with .NET on it. So I started with this image and basically copied how Microsoft installs .NET. I needed to do it this way because my application also installs some custom drivers onto the operating system. There may be a better way but I haven't seen it yet.

# 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

Upvotes: 1

Agendum
Agendum

Reputation: 2021

I think I figured this out. It seems like the image 'mcr.microsoft.com/dotnet/core/runtime:3.1.1' is just a "layer" which only contains the recipe needed to install the runtime, but doesn't contain the underlying OS specification (please correct me if that is wrong). Therefore, I first need to provide the OS, and install to that, then apply the .NET Core runtime. This seems to work:

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

Upvotes: 3

Related Questions