在 Windows 10 上执行此操作:
>docker-compose -f docker-compose.yml build
Building MyApprestapi
Step 1/17 : FROM microsoft/aspnetcore:2.0 AS base
---> 6237a4750408
Step 2/17 : WORKDIR /app
Removing intermediate container ae0057e8752c
---> d422fca6b533
Step 3/17 : EXPOSE 11001
---> Running in 70f6f9a9d052
Removing intermediate container 70f6f9a9d052
---> 673d1c1d8f34
Step 4/17 : FROM microsoft/aspnetcore-build:2.0 AS build
---> f5f1d9a332af
Step 5/17 : WORKDIR /src
Removing intermediate container 0c5e68914dfd
---> 035e0d5467bf
Step 6/17 : COPY MyAppPipeline.sln ./
---> b0ccbf6431b4
Step 7/17 : COPY MyAppRestApi/MyAppRestApi.csproj MyAppRestApi/
---> 3216ad77f880
Step 8/17 : RUN dotnet restore -nowarn:msb3202,nu1503
---> Running in f0b9fa8dbbd4
C:\Program Files\dotnet\sdk\2.1.200\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1. [C:\src\MyAppRestApi\MyAppRestApi.csproj]
ERROR: Service 'MyApprestapi' failed to build: The command 'cmd /S /C dotnet restore -nowarn:msb3202,nu1503' returned a non-zero code: 1
如果我这样做:
>dotnet --info
最佳答案
问题是我的 DockerFile 是在项目创建时生成的。
我不得不使用这里列出的替代品:
https://github.com/dotnet/dotnet-docker
microsoft/dotnet:2.1-aspnetcore-runtime
microsoft/dotnet:2.1-sdk
关于Docker 构建失败,当前 .NET SDK 不支持面向 .NET Core 2.1,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50787895/