问题描述
请帮助我解决此问题,它已成为我的主要障碍。
工具:
1.Microsoft Visual Studio Enterprise 2019版本16.7.1
2. Docker桌面(Docker版本19.03.12,内部版本48a66213fe)
问题:
通过Dockerfile构建映像时,运行dotnet restore命令失败。
如果我在命令提示符下运行相同的“ dotnet restore命令”,则说明该命令执行成功。
我到目前为止所做的事情:
-
我重新安装了VS 2019和docker桌面,但无济于事。
-
我试图从其他论坛获得答案,但没有帮助。
**DockerFile**: FROM mcr.microsoft.com/dotnet/core/aspnet:2.1 AS base EXPOSE 80 FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build WORKDIR /src COPY ["PatientService/PatientService.csproj","PatientService/"] RUN dotnet restore "PatientService/PatientService.csproj" COPY . . WORKDIR "/src/PatientService" RUN dotnet build "PatientService.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "PatientService.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet","PatientService.dll"] **Output**: 1>------ Rebuild All started: Project: PatientService,Configuration: Debug Any CPU ------ 1>PatientService -> D:\Projects_Exercise\PatientService\PatientService\bin\Debug\netcoreapp2.1\PatientService.dll 1>Docker version 19.03.12,build 48a66213fe 1>docker build -f "d:\projects_exercise\patientservice\patientservice\dockerfile" --force-rm -t patientservice --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=PatientService" "d:\projects_exercise\patientservice" 1>Sending build context to Docker daemon 70.66kB 1> 1>Step 1/17 : FROM mcr.microsoft.com/dotnet/core/aspnet:2.1 AS base 1> ---> cd464c4949df 1>Step 2/17 : EXPOSE 80 1> ---> Using cache 1> ---> 113b7b4da631 1>Step 3/17 : FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build 1> ---> 58b9fa67619f 1>Step 4/17 : WORKDIR /src 1> ---> Using cache 1> ---> 63c1068fe906 1>Step 5/17 : COPY ["PatientService/PatientService.csproj","PatientService/"] 1> ---> Using cache 1> ---> e9dd2773b565 1>Step 6/17 : RUN dotnet restore "PatientService/PatientService.csproj" 1> ---> Running in 64786399b7ae 1>C:\Program Files\dotnet\sdk\2.1.809\NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\PatientService\PatientService.csproj] 1>C:\Program Files\dotnet\sdk\2.1.809\NuGet.targets(123,5): error : No such host is known [C:\src\PatientService\PatientService.csproj] 1>Removing intermediate container 64786399b7ae 1>The command 'cmd /S /C dotnet restore "PatientService/PatientService.csproj"' returned a non-zero code: 1 1>d:\projects_exercise\patientservice\patientservice\dockerfile : error CTC1014: Docker command failed with exit code 1. 1>d:\projects_exercise\patientservice\patientservice\dockerfile : error CTC1014: The command 'cmd /S /C dotnet restore "PatientService/PatientService.csproj"' returned a non-zero code: 1 1>Done building project "PatientService.csproj" -- FAILED. ========== Rebuild All: 0 succeeded,1 failed,0 skipped ==========
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)