【发布时间】:2018-04-26 09:21:55
【问题描述】:
https://github.com/dotnet/dotnet-docker-samples/tree/master/aspnetapp
Docker 命令docker build -t aspnetapp.
docker build 命令出错
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): 错误:无法加载源 https://api.nuget.org/v3/index.json 的服务索引。 [C:\app\aspnetapp.csproj]
[1]PS C:\Users\pssharma\dotnet-docker-samples\aspnetapp> docker build -t aspnetapp .
Sending build context to Docker daemon 2.444MB
Step 1/10 : FROM microsoft/aspnetcore-build:2.0 AS build-env
---> eb21d939e0d8
Step 2/10 : WORKDIR /app
---> Using cache
---> d4ec30216ed7
Step 3/10 : COPY *.csproj ./
---> Using cache
---> 2ff39b5e6cb4
Step 4/10 : RUN dotnet restore
---> Running in 776764a35311
Restoring packages for C:\app\aspnetapp.csproj...
Restoring packages for C:\app\aspnetapp.csproj...
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\asp
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : An error occurred while sending the request. [C:\app\aspnetapp.csproj]
C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : The operation timed out [C:\app\aspnetapp.csproj]
以下命令返回一个非零代码:1
powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore
【问题讨论】:
-
在几个早期版本中,我必须重新启动 docker 服务才能解决此类问题。您能否尝试重新启动它并从管理员 powershel 控制台重试构建:
Restart-Service com.docker.service -Force -
嗨,我尝试使用管理员 PowerShell,但得到了同样的错误。
-
您可以尝试在您的 DockerFile 中添加
RUN curl https://api.nuget.org/v3/index.json -v和RUN dotnet restore --verbosity diag以查看它在做什么 - 如果只是恢复失败或两者都使用 curl。 -
我得到同样的错误这是 Dockerfile FROM microsoft/aspnetcore-build:2.0 AS build-env WORKDIR /app # 复制 csproj 并恢复为不同的层 COPY *.csproj ./ RUN dotnet restore # 复制所有内容否则并构建 COPY 。 ./ RUN dotnet publish -c Release -o out # 构建运行时映像 FROM microsoft/aspnetcore:2.0 WORKDIR /app COPY --from=build-env /app/out 。入口点 ["dotnet", "aspnetapp.dll"]
-
我遇到了同样的问题。你解决了吗?
标签: docker