【发布时间】:2020-06-29 05:27:30
【问题描述】:
我正在使用 docker-compose 在 .Net core 3.1 中开发微服务。我们正在使用基于 Linux 的 Docker 容器。 MVC 客户端应用程序与 Identity 4 API 一起在 IIS express 中完美运行,当我在 docker-compose 中运行微服务时,客户端应用程序出现错误。
{"StatusCode":500,"Message":"内部服务器错误。"}
在 MVC 客户端容器中,我检查了容器的日志。我收到以下错误。
Unable to obtain configuration from 'http://localhost:44338/.well-known/openid-configuration'
以上 URL 代表同样在容器中运行的 Identity Server 4。 我的 docker-compose 的顺序是
version: '3.4'
services:
identity.api:
environment:
- ASPNETCORE_URLS=https://+:443;http://+:80
- MvcClient=http://localhost:44353
ports:
- "44338:80"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
rinmvc:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80;
- ASPNETCORE_URLS=http://0.0.0.0:80
- IdentityUrl=http://localhost:44338
ports:
- "44353:80"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
【问题讨论】:
-
由于是在docker中运行,mvc客户端和Identityserver不在同一个localhost。您可能希望将 IdentityUrl 更改为 identity.api:44338
-
identity.api 要好得多,而不是与端口一起使用
标签: docker-compose containers asp.net-core-webapi identityserver4