Tag: .net core

Identity Server 4和Docker

我试图configurationDocker的IdentityServer4,但我不能让它的工作。 为了开始,我使用了身份服务器文档的Client Credential示例: 使用Client Credentials保护API IdentityServer 托pipe在5000端口上 的WebAPI 托pipe在港口5001 在我的WebApi的Startup.cs文件的Configure方法中,我做了以下操作(问题可能在这里): app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions { Authority = "http://web:5000", RequireHttpsMetadata = false, ApiName = "api1" }); 客户 和客户 // Everything is fine here… var disco = await DiscoveryClient.GetAsync("http://localhost:5000"); var tokenClient = new TokenClient(disco.TokenEndpoint, "client", "secret"); var tokenResponse = await tokenClient.RequestClientCredentialsAsync("api"); // This does not work var client = […]

在Docker中运行.Net Core 2.0上的IdentityServer4 – 访问主机资源

我试图将一个.Net Core 2.0应用程序的服务(IdentityServer 4 v2)转换为在Docker for Windows上运行。 这只在开发工作站上。 我做了标准的Visual Studio 2017“添加Docker支持”到现有的Net Core 2.0服务。 服务启动正常,但由于这些问题而失败: 该服务正在寻找安装在本地主机上的证书。 在Docker中运行它没有看到这个证书。 该服务使用主机的etc / host文件来查找我们的数据库服务器的DNS。 在Docker上运行的服务没有看到主机的DNS。 我试图将docker中的network_mode设置为“host”,但无法构build。 build立这样一个环境的build议方式是什么? 运行时是使用docker撰写的,默认的撰写和configuration非常简单: version: '3' services: identity.server: image: identity.server ports: – "8100:8100" build: context: ./src/Identity.Server dockerfile: Dockerfile 引用的dockerfile: FROM microsoft/dotnet:2.0-runtime ARG source WORKDIR /app COPY ${source:-obj/Docker/publish} . ENTRYPOINT ["dotnet", "Identity.Server.dll"] 我已经阅读了下面的答案,但它似乎不工作在.net本身: https : //devops.stackexchange.com/questions/1501/configure-docker-to-use-ssl-for-a-private -registry上-窗口10?newreg […]

保持Dotnet Core Grpc Server作为控制台应用程序运行?

我试图让一个Grpc服务器作为一个控制台守护进程运行。 这个gRPC服务器是一个在Docker容器中运行的微服务。 我可以find的所有例子都使用以下内容: Console.ReadKey(); 这确实阻塞主线程,并保持运行,但在docker中不起作用,出现以下错误: "Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read." 现在我可以尝试finddocker的解决方法,但这仍然不太合适。 有没有人知道一个好的“生产准备”的方式来保持服务运行?

在Windows的Windows子系统中运行Docker中的.Net Core

实际上,我想在Docker中使用.NET Core。 因此,据我了解,从这个职位给自己最好的灵活性,我会安装“Docker的Windows”。 意味着我可以最终将我的.Core应用程序部署到一个Windows或Linux容器的容器。 但是,Linux容器仍然是一个Hyper-Vpipe理的Linux容器。 1)有没有办法改为使用Windows子系统的Linux(WSL)在Windows 10创build者更新中执行此操作? 似乎比Windows / Docker为我pipe理单独的Linux虚拟机花费更less?

为什么这个dotnettesting只在Docker容器中运行崩溃?

我有这个.NET Core 1.1解决scheme,包括一个ASP.NET Core项目和一个NUnittesting项目。 每个项目都有必要的属性(如果需要,我可以显示更多)。 <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> </PropertyGroup> 我可以在本地恢复,构build和运行testing套件(Windows 10),没有任何问题。 $ dotnet restore Restoring packages for… Restore completed in… Generating MSBuild file… $ dotnet build Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved. Example -> … Test -> … Build succeeded. 0 Warning(s) 0 Error(s) Time […]

Docker中运行的Dotnet核心Web API在使用外部WCF服务时无法进行身份validation

我正在使用dotnet核心1.1.2构build一个RESTful API。 这个api的很大一部分需要向外部WCF服务发出请求。 这些请求通过使用用户名,密码和域的基于Windows的身份validation进行身份validation。 我目前正在准备API生产的过程,我想尝试dockerizing它。 我遇到的问题是,只要从Docker容器中调用此身份validation,此身份validation就无法通过此第三方WCF服务。 使用dotnet运行时API运行在Windows和Mac上,并且服务得到authentication。 我使用Visual Studio 2017的Connect wcf服务function来使用WCF服务,然后使用正确的身份validation模式修改端点绑定。 public ServiceSoapClient(EndpointConfiguration endpointConfiguration, string username, string password, string domain) : base(ServiceSoapClient.GetBindingForEndpoint(endpointConfiguration), ServiceSoapClient.GetEndpointAddress(endpointConfiguration)) { this.ChannelFactory.Credentials.Windows.ClientCredential.UserName = username; this.ChannelFactory.Credentials.Windows.ClientCredential.Password = password; this.ChannelFactory.Credentials.Windows.ClientCredential.Domain = domain; this.Endpoint.Name = endpointConfiguration.ToString(); ConfigureEndpoint(this.Endpoint, this.ClientCredentials); } private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) { if ((endpointConfiguration == EndpointConfiguration.ServiceSoap)) { System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(); […]

如何代理Docker容器中运行的一个dotnet核心应用程序的每个请求

我正努力从一个web代理运行在docker上的容器代理http请求我的http调用。 我已经通过代理使用bash成功达到了所需的端点 docker exec -i -t 665b4a1e17b6 /bin/bash 和 http_proxy=http://exampleProxy:7777 curl -s http://endpoint 现在我想从在同一个容器上运行的应用程序中重新创build它 我已经尝试了以下内容: dotnet核心代理 loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc().RunProxy(new ProxyOptions { Scheme = "http", Host = "example", Port = "7777" }); 在创build容器时设置http_proxy环境variables export http_proxy=http://example:7777 使用HttpClientHandler var handler = new HttpClientHandler { Proxy = new WebProxy("http://example:777) }; var client = new HttpClient(handler); etc…. 任何人都可以想到其他方式来设置代理? 或者有关如何debugging的任何build议?

在ASP.NET Core中构builddocker:“没有这样的文件或目录”错误

当我build立我的docker时,出现错误。 Sending build context to Docker daemon 3.584 kB Step 1/8 : FROM microsoft/aspnetcore:1.1 —> 2628aaa7b8cf Step 2/8 : ENV ASPNETCORE_URLS "http://*:5000" —> Using cache —> 5dffde204fef Step 3/8 : ENV ASPNETCORE_ENVIRONMENT "Development" —> Using cache —> 3064358bc0eb Step 4/8 : ARG source —> Using cache —> 4159d0eb78c0 Step 5/8 : WORKDIR /app —> Using […]

Docker中用于.NET Core应用程序的appSettings.json?

我在Docker容器中运行.net核心应用程序。 这是我的docker文件(只是为了build立一个开发环境): FROM microsoft/dotnet:1.0.1-sdk-projectjson ENV ASPNET_ENV Development COPY bin/Debug/netcoreapp1.0/publish/ /root/ EXPOSE 5000/tcp ENTRYPOINT dotnet /root/AVP.WebApi.dll 我在/ publish /文件夹中有一个appSettings.Development.json文件。 如果我构build并运行这个Docker文件,我最终会遇到一个奇怪的问题,.NET应用程序无法find它需要启动的appsettings(它们在appSettings.Development.json文件中)。 我已经确认,从Windows命令行如果我运行dotnet发布/ AVP.WebAPI.dll该应用程序抛出相同的例外,缺lessconfiguration设置。 但是,如果我cd /发布和运行dotnet AVP.WebAPI.dll应用程序启动和运行就好了。 任何想法如何更改我的docker文件,所以它会正确运行与appSettings.Development.json值的应用程序? (我也试图运行应用程序与所有值复制到常规appSettings.json文件没有运气) 我也尝试运行一个COPY命令来/而不是/ root和做dotnet AVP.WebApi.dll作为入口点,但是这导致项目无法find依赖关系。

从Docker容器连接到SQL Server数据库

我有我的机器上安装的窗口泊坞窗。 有一个控制台应用程序以.net core 1.0.0为目标,试图访问运行在不同虚拟机上的SQL Server数据库。 我可以从我的机器上ping运行SQL Server的VM。 当我尝试从我的机​​器上的命令提示符dotnet run使用dotnet run控制台应用程序它工作正常。 但是当相同的应用程序在Docker容器中运行时,我收到一条消息 与SQL Serverbuild立连接时发生networking相关或特定于实例的错误。 服务器未find或无法访问。 validation实例名称是否正确,并将SQL Serverconfiguration为允许远程连接。 (提供程序:TCP提供程序,错误:40 – 无法打开到SQL Server的连接) 我试过使用 docker run –add-host sqldemo:<VM running sql server ip here> 但这没有什么区别。