简体   繁体   中英

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.

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. 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. Dotnet watch does not seems work work well with the localhost url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM