gpt4 book ai didi

asp.net - Windows Docker 镜像无法访问互联网

转载 作者:行者123 更新时间:2023-12-03 01:22:17 25 4
gpt4 key购买 nike

我有一个用 Net 5 Core 编写的应用程序,但依赖项必须在 Windows 平台上运行,并且我必须使用 Windows 容器。应用程序运行的一些值存储在 Azure 数据库中。构建镜像后,我启动容器,但由于无法从基础读取数据,容器崩溃了。其他可以在 Linux 下运行的应用程序可以从库中读取值。也许需要实现一些防火墙设置和 Windows 镜像才能工作?

FROM mcr.microsoft.com/dotnet/aspnet:5.0-nanoserver-1809 AS base
#FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80


FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src


COPY ["/src/Configurations/appsettings.json", "Configurations/"]
COPY ["/src/TestEngine/.", "TestEngine/"]


RUN dotnet restore "TestEngine/TestEngine.App/TestEngine.App.csproj"
COPY . .
WORKDIR "TestEngine/TestEngine.App/"
RUN dotnet build "TestEngine.App.csproj" -c Release -o /app/build --no-restore

FROM build AS publish
RUN dotnet publish "TestEngine.App.csproj" -c Release -o /app/publish --no-restore

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "TestEngine.App.dll"]

错误

System.ArgumentNullException: Value cannot be null. (Parameter 'uriString')
at System.Uri..ctor(String uriString)
at TestEngine.App.Startup.ConfigureServices(IServiceCollection services) in C:\src\TestEngine\TestEngine.App\Startup.cs:line 80
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)

谢谢)

最佳答案

似乎有几种不同的东西会破坏 Windows 容器的互联网。为我解决了几次问题的是“docker网络修剪”,然后重新启动计算机,因此它重新创建了默认网络。

破坏性较小的选项是在命令中使用“默认开关”网络,例如:

docker run --network "Default Switch" ...
docker build --network "Default Switch" ...

关于asp.net - Windows Docker 镜像无法访问互联网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69408571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com