[英]Windows Docker image has no internet access
I have an application written in Net 5 Core, but the dependencies must work on the Windows platform and I must use Windows containers.我有一个用 Net 5 Core 编写的应用程序,但依赖项必须在 Windows 平台上运行,我必须使用 Windows 容器。 Some values for the application to work are stored in the Azure database.
应用程序工作的一些值存储在 Azure 数据库中。 After the build of the image, I launch the container and it crashes due to the inability to read the data from the base.
构建映像后,我启动了容器,但由于无法从基础读取数据而崩溃。 Other applications that can be run under Linux they can read values from the base.
可以在 Linux 下运行的其他应用程序可以从基数中读取值。 Perhaps there are some firewall settings that need to be implemented and Windows images so that they can work?
也许需要实施一些防火墙设置和 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"]
error错误
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)
Thanks)谢谢)
There seems to be several different things that break inte.net for windows containers.似乎有几种不同的东西破坏了 windows 容器的 inte.net。 What solved it for me a few times was a "docker.network prune" followed by restarting the computer, so it recreates it's default.networks.
几次为我解决的是“docker.network prune”,然后重新启动计算机,因此它重新创建了 default.networks。
A less destructive option was using the "Default Switch".network in your commands, like:一个破坏性较小的选项是在您的命令中使用“默认开关”.network,例如:
docker run --network "Default Switch" ...
docker build --network "Default Switch" ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.