简体   繁体   English

无法连接到在 docker 容器内运行的 ASP.NET Core 6 应用程序

[英]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.

相关问题 (IdentityServer4) 如何在 Docker 容器中运行的 Asp.Net Core 应用程序中加载 X509 证书 - (IdentityServer4) How Do I Load A X509 Certificate Inside An Asp.Net Core Application Running In A Docker Container 如何为在本地 Docker 或 Kubernetes 中运行的 ASP.NET Core 应用程序连接本地 SQL Server 数据库? - How do I connect the local SQL Server database for the ASP.NET Core application running inside either local Docker or Kubernetes? 在 Docker 中运行 ASP.NET Core 应用程序时丢失文件:如何在容器运行时显示文件? - Missing files when running ASP.NET Core application in Docker: How to display files when the container is running? 无法从docker windows容器中的asp.net核心应用程序连接到主机数据库 - Not able to connect to host database from asp.net core application which is in docker windows container ASP.NET Core 6 在 docker 容器中运行时无法解析数据库名称(在 WSL2 中) - ASP.NET Core 6 cannot resolve database name when running in docker container (in WSL2) 如何从在容器中运行的 ASP.NET 核心应用程序连接到具有集成安全性的 Windows 服务器上的 SQL 服务器 - How to connect from ASP.NET Core application running in a container to SQL Server on Windows Server with Integrated Security Asp.NET 核心 WebAPI 未在 docker 容器中运行 - Asp.NET Core WebAPI not running in docker container 无法从主机连接到Docker容器内的.net核心网站 - Cannot connect from host to .net core website inside docker container ASP.NET 核心 在 Docker 容器内加载 Onnx 文件 - ASP.NET Core Load an Onnx file inside a Docker container 无法构建 docker 容器(ASP.NET Core) - Cannot build docker container (ASP.NET Core)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM