windows - Azure 应用服务上的 ASP.NET Core 2.1 Docker 容器的正确 Windows 基本镜像是什么

标签 windows azure docker asp.net-core azure-web-app-service

我想创建一个可以托管在适用于 Windows 的 Azure 应用服务上的 Docker 镜像。我的应用程序基于 ASP.NET Core 2.1 并根据 official list of .NET images images ,我应该能够简单地使用 microsoft/dotnet:2.1-aspnetcore-runtime

我可以在 Windows 计算机上成功构建 Dockerfile,并且能够毫无问题地在那里运行它。但是将其上传到 Docker Hub 并将其设置为应用服务的 Docker 镜像后,我收到以下错误消息:

Cannot run this Operating System/Version in Windows Containers. Maximum supported OS version is 10.0.14393.9999.

根据Azure App Services Documentation ,它应该支持 microsoft/dotnet:2.1-aspnetcore-runtime 作为预安装的父镜像之一。

在检查我的 Docker 镜像时,我发现所使用的镜像对于 Azure 应用服务来说似乎太新了:

"Architecture": "amd64",
"Os": "windows",
"OsVersion": "10.0.17134.285" <-- too new

经过一番研究,我 found in this blog post ,Windows 上的 Azure 应用服务可能只接受 microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 镜像。所以我尝试用这些重建 Docker 镜像。

这一次,应用服务接受了该镜像,但无法启动它,并抛出以下日志:

02/10/2018 14:15:09.437 ERROR - Site: rothiewindockerdemo - Image pull reported error. Image: robinmanuelthiel/contosomaintenance-api:latest-windows-sac2016. failed to register layer: re-exec error: exit status 1: output: remove \\?\C:\DockerData\windowsfilter\93b716197958ceb58006ff3d978fcb3202f7866d00d6d8d69513cf0478a17a7f\UtilityVM\Files\Windows\servicing\Packages\Microsoft-UtilityVM-Core-Package~31bf3856ad364e35~amd64~~10.0.14393.0.cat: The process cannot access the file because it is being used by another process.
02/10/2018 14:15:09.437 INFO - Site: rothiewindockerdemo - Image: robinmanuelthiel/contosomaintenance-api:latest-windows-sac2016
Custom Registry: https://index.docker.io

02/10/2018 14:15:09.439 ERROR - Site: rothiewindockerdemo - Pull image completed but it was not found locally. Image: robinmanuelthiel/contosomaintenance-api:latest-windows-sac2016
02/10/2018 14:15:09.441 WARNING - Site: rothiewindockerdemo - Attempt 1 to start container was unsuccessful. Maximum attempts: 3. 
02/10/2018 14:15:09.568 INFO - Site: rothiewindockerdemo - Purging after container failed to start
02/10/2018 14:15:09.582 INFO - Site: rothiewindockerdemo - Purging pending logs after stopping container

那么 Azure 应用服务上的 ASP.NET Core 2.1 Docker 容器的正确 Windows Docker 基础镜像是什么?

这是我的Dockerfile:

#######################################################
# Step 1: Build the application in a container        #
#######################################################

# Download the official ASP.NET Core SDK image 
# to build the project while creating the docker image
FROM microsoft/dotnet:2.1-sdk as build
WORKDIR /app

# Restore NuGet packages
COPY *.csproj .
RUN dotnet restore

# Copy the rest of the files over
COPY . .

# Build the application
RUN dotnet publish --output /out/ --configuration Release

#######################################################
# Step 2: Run the build outcome in a container        #
#######################################################

# Download the official ASP.NET Core Runtime image
# to run the compiled application
FROM microsoft/dotnet:2.1-aspnetcore-runtime

WORKDIR /app

# Open HTTP and HTTPS ports
EXPOSE 80
EXPOSE 443

# Copy the build output from the SDK image
COPY --from=build /out .

# Start the application
ENTRYPOINT ["dotnet", "MyApp.dll"]

最佳答案

问题在于 microsoft/dotnet:2.1-aspnetcore-runtime 是一个多架构基础镜像。这意味着 Docker 构建将为您的本地计算机(您正在构建 Docker 镜像的计算机)选择最佳架构。我假设您的本地计算机是 Windows 10 April 2018 Update(版本 1803 - 内部版本号 17134.407)。截至目前,我们仅支持基于 Windows Server 2016(版本 1709,最高版本号 14393.XX)的镜像。

为了“强制”使用特定版本,请改用此基础镜像:microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016。您可以在 https://hub.docker.com/r/microsoft/dotnet/ 中查看所有可用标签

我们将努力在我们的文档中专门指出这一点。

关于windows - Azure 应用服务上的 ASP.NET Core 2.1 Docker 容器的正确 Windows 基本镜像是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52610319/

相关文章:

azure - 将 CreateTableIfNotExists 或DoesTableExist 与Azure 表存储结合使用是否有任何开销?

azure - 终于将 Key Vault 与 AKS 集成...但不清楚我需要做什么,如果之后有任何事情要读入环境变量

azure - 向 Azure Functions 中 SignalR 服务中的一组用户发送消息

docker - ekito/cron作业教程出错

node.js - 如何在基于 Node.js 镜像的 Docker 容器中使用 Let's Encrypt

c# - 检测整个系统何时发生粘贴事件

windows - REBASE.EXE 的替代品是什么?

windows - 如何在 Windows 上获取最新的 git 标签?

linux - 如何在docker中查找FTP主机以及用户名和密码

python - 为什么我不能从Windows上的pip下载我的软件包的最新版本?