You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker中dotnet restore失败:无法加载私有NuGet源服务索引(NU1301)

NU1301: Docker执行dotnet restore时无法加载源的服务索引

在Dockerfile中执行dotnet restore <project>命令时,触发NU1301: Unable to load the service index for source错误,已尝试以下排查操作但问题仍未解决:

  • 将Docker Engine的DNS设置为8.8.8.8
  • 使用Linux容器
  • 执行RUN ping google.com成功,容器可正常访问互联网
  • 能正常访问nuget.org源
  • nuget.config文件中配置了凭据(后续会替换方案,且凭据与本地开发使用的用户名/PAT一致)
  • 执行RUN curl <nuget_feed_url>成功,可访问私有NuGet源地址
  • 添加--verbosity detailed参数执行restore,仅返回上述错误,无额外信息

相关Dockerfile片段

FROM mcr.microsoft.com/dotnet/aspnet:6.0.13 AS base
# Create dockeruser in base layer
RUN addgroup --system --gid 1000 dockergroup \
    && adduser --system --uid 1000 --ingroup dockergroup --shell /bin/sh dockeruser

WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
# Arguments are required in each stage in order to get the correct value

WORKDIR /src
COPY ["src/Nucleus.LumberYard.API/", "Nucleus.LumberYard.API/"]
COPY ["./nuget.config", "./nuget.config"]

WORKDIR "/src/Nucleus.LumberYard.API"
#COPY [".editorconfig", "./"]
RUN dotnet restore "Nucleus.LumberYard.API.csproj"
RUN dotnet build "Nucleus.LumberYard.API.csproj" -c Release --no-restore

环境信息

  • Docker Desktop v3.3.1
  • Docker v20.10.5

内容的提问来源于stack exchange,提问作者Logan K

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 17:40:58