我一直在尝试为我的asp.net网络api创建一个dockerfile。互联网上的许多指南都使用此RUN dotnet restore RUN dotnet publish命令,但是我在这里遇到错误。
我的dockerfile:
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
EXPOSE 5000
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "myTest.dll"]
然后我遇到这个错误:
Step 5/11 : RUN dotnet restore
---> Running in 592b7df3e0f6
Restoring packages for C:\app\myTest.csproj...
C:\Program Files\dotnet\sdk\2.1.402\NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\myTest.csproj]
C:\Program Files\dotnet\sdk\2.1.402\NuGet.targets(114,5): error : No such host is known [C:\app\myTest.csproj]
The command 'cmd /S /C dotnet restore' returned a non-zero code: 1
有人可以解释/帮助我吗?