I have a project built using .net 2.2. Here is the dockerfile from one of the services:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS publish
WORKDIR /src
COPY Identity.Api.csproj .
RUN dotnet restore MyApp.Api.csproj
COPY . .
RUN dotnet publish "MyApp.Api.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]
For my colleagues, they can pull this project and docker build using this dockerfile when running Docker Desktop using Linux Containers. But for me, for some weird reason, when I try to docker build, I get the following error
Step 8/14 : RUN dotnet restore MyApp.Api.csproj
---> Running in 99df436556bb
/usr/share/dotnet/sdk/2.2.207/NuGet.targets(119,5): error : An error occurred while retrieving package metadata for 'System.Memory.4.5.1' from source '/usr/share/dotnet/sdk/NuGetFallbackFolder'. [/src/MyApp.Api.csproj]
/usr/share/dotnet/sdk/2.2.207/NuGet.targets(119,5): error : Root element is missing. [/src/MyApp.Api.csproj]
The command '/bin/sh -c dotnet restore MyApp.Api.csproj' returned a non-zero code: 1
Here is my dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.102
Commit: 71365b4d42
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk5.0.102
Host (useful for support):
Version: 5.0.2
Commit: cb5f173b96
.NET SDKs installed:
2.1.400 [C:Program Filesdotnetsdk]
2.1.520 [C:Program Filesdotnetsdk]
2.2.107 [C:Program Filesdotnetsdk]
5.0.101 [C:Program Filesdotnetsdk]
5.0.102 [C:Program Filesdotnetsdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.24 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.24 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.24 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 3.1.11 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.11 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
However, if I switch to Windows Containers, I can get this project to docker build.
I can't figure out what is unique about my environment.
I have Docker Container running WSL2.
PS c:> wsl -l -v
NAME STATE VERSION
* docker-desktop-data Stopped 2
docker-desktop Stopped 2
Any help appreciated.
question from:
https://stackoverflow.com/questions/65854925/dotnet-core-aspnet-2-2-image-works-on-windows-containers-but-not-linux 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…