【发布时间】:2020-07-28 11:11:14
【问题描述】:
我有 2 个 Docker: 我的 ASP.NET Core Web 服务器 -p 5001:80 postgresql -p 5451:5432 当我配置我的 Web 服务器以使用在我的主机上运行的 postgresql 时,它可以工作。 但是当我在 Docker 中运行 configure myWeb App 以使用 postgresql 时,运行 http://localhost:5001 它
starts but then an error appears:
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (99): Cannot assign requested address [::1]:5451
如果我将应用程序连接到外部非 dockerized PostgreSQL - 它工作正常。
什么不正确以及如何解决?
有我的 docker-compose 文件
【问题讨论】:
-
你是如何运行容器的?
docker-compose还是docker run?请添加您用于运行容器的命令 -
你应该使用容器端口
5432而不是5451使用docker-compose网络发布端口 -
@ChristianFosli 我在 docker-compse 中运行 postgres docker:它包含 postgresl、elastic、kibana。我运行的网络应用程序:>docker run -it --rm -p5901:5901 pman。此外,我已将其包含在同一个组合中。但是该应用程序有一个 PG 连接字符串:localhost。我已将其替换为 0.0.0.0 0 都给出了错误。
标签: docker asp.net-core