簡體   English   中英

什么是Azure App Services上的ASP.NET Core 2.1 Docker容器的正確Windows基礎映像

[英]What's the correct Windows Base Image for ASP.NET Core 2.1 Docker Containers on Azure App Services

我想創建一個可以在Azure App Services for Windows上托管的Docker鏡像。 我的應用程序基於ASP.NET Core 2.1,根據官方的.NET圖像列表 ,我應該能夠簡單地使用microsoft/dotnet:2.1-aspnetcore-runtime

我可以成功地在Windows機器上構建Dockerfile,並且能夠在那里運行它而不會出現問題。 但在將其上傳到Docker Hub並將其設置為App Service的Docker Image后,我收到以下錯誤消息:

無法在Windows容器中運行此操作系統/版本。 支持的最大操作系統版本為10.0.14393.9999。

根據Azure應用服務文檔 ,它應該支持microsoft/dotnet:2.1-aspnetcore-runtime作為預安裝的父映像之一。

在檢查我的Docker Image時,我發現,使用過的圖像對於Azure App Services來說似乎太新了:

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

經過一些研究,我在這篇博文中發現, Windows上的Azure App Services可能只接受microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016圖像。 所以我嘗試用這些重建Docker鏡像。

這次,App Service接受了圖像,但無法啟動它,拋出以下日志:

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 App Services上的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/中查看所有可用的標簽

我們將努力在我們的文檔中專門調用它。

值得一提的是,App Service上的Windows Containers目前處於預覽狀態。

門戶網站上的驗證“無法在Windows容器中運行此操作系統/版本。支持的最大操作系統版本為10.0.14393.9999。” 顯示是因為我們使用Windows Server 2016 RS1運行服務器,並且當前無法運行RS3 +的容器。 我們目前正致力於實現這些目標,但此時我們尚未分享ETA。

如果驗證通過,則意味着指定的圖像應該正常工作,您看到的問題與圖像沒有直接關系。 這是平台中的一個錯誤,它似乎與此處報告的問題類似: https//github.com/Microsoft/hcsshim/issues/155

我們將繼續調查並感謝您報告此問題

上面的答案被標記為答案是不正確的。 它讓你相信使用microsoft / dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016將解決你的問題,但事實並非如此。 我在Azure容器實例上測試了這個,但它不起作用。

解決方案是這樣的:當您獲得OsVersionNotSupported時,意味着該圖像是使用不受支持的Windows版本創建的,並且Microsoft目前不支持任何SAC版本(SAC是半年度頻道)。 所以像1709和1803這樣的版本將無效。 此外,上面的“解決方案”不起作用,因為它使用SAC2016的標簽。

對於您可以在docker文件中使用的所有標簽,請訪問: https//github.com/dotnet/dotnet-docker/blob/master/TAGS.md

您需要訪問https://docs.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting並閱讀“不支持的操作系統版本的圖像”部分。 它清楚地表明你需要“......總是部署基於Windows Server 2016(LTSC)的圖像......”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM