我已经看到许多有关退出代码3221225781的问题,以响应docker RUN,但是我仍然找不到答案。考虑以下dockerfile:
events = []
recurring_events = RecurringEvent.objects.filter(date_start__gte=datetime.utcnow())
recurring_events_info = []
for event in recurring_events:
if event.info not in recurring_events_info:
recurring_event = RecurringEvent.objects.filter(date_start__gte=datetime.utcnow(), info=event.info).order_by('-date_start').first()
events.append(recurring_event)
recurring_events_info.append(event.info)
运行此命令时,将得到以下输出:
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
为什么我会得到这个退出代码?这是什么意思?我还确认未写入vc_redist.log。
有人知道我该怎么做才能使它工作?
我应该补充一点,该命令在本地计算机上运行时会起作用,并且返回零%ERRORLEVEL%。
谢谢!
答案 0 :(得分: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
答案 1 :(得分:1)
@ProfNimrod我需要使用具有Azure可以使用的操作系统的映像,而不仅仅是其中带有.NET的层。因此,我从这张图片开始,基本上复制了Microsoft如何安装.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