[英]Cannot connect to an ASP.NET Core 6 application running inside a docker container
I am running an ASP.NET Core 6 Web API project inside a Docker container.我在 ZC5FD214CDD0D2B2BA54272E73B20 容器内运行 ASP.NET Core 6 Web API 项目。
I use the watch command to run the application, which I know is running inside the container, because I ran a curl command in the container.我使用 watch 命令运行应用程序,我知道它在容器内运行,因为我在容器中运行了 curl 命令。 Also volumes are correctly mapped, because whenever I make changes they are picked up judging form the container logs.
卷也被正确映射,因为每当我进行更改时,它们都会根据容器日志进行判断。
version: "3"
services:
backend:
container_name: backend
image: mcr.microsoft.com/dotnet/sdk:6.0
ports:
- 5048:5048
working_dir: /backend
volumes:
- .:/backend:cached
command: sh -c "dotnet dev-certs https && dotnet watch"
I get an error message saying The connection to the server was reset while the page was loading.我收到一条错误消息,提示页面加载时与服务器的连接已重置。 in browser.
在浏览器中。
I managed to get it to work by changing the urls for the hot reload profile in launch settings from http(s)://localhost:port to http(s)://0.0.0.0:port.我设法通过将启动设置中热重载配置文件的 url 从 http(s)://localhost:port 更改为 http(s)://0.0.0.0:port 来使其工作。 Dotnet watch does not seems work work well with the localhost url.
Dotnet watch 似乎不适用于 localhost url。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.