dotnet watch run in dockerfile does not work

  .net-core, dockerfile, linux

Im working with docker containers on linux os, and trying to debug an dotnet core web api application that runs inside docker container.

here is my docker file

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["simplewebapi/simplewebapi.csproj", "simplewebapi/"]
RUN dotnet restore "simplewebapi/simplewebapi.csproj"
COPY . .
WORKDIR "/src/simplewebapi"
RUN dotnet build "simplewebapi.csproj" -c Release -o /app/build
CMD dotnet watch run --urls "http://0.0.0.0:5050;https://0.0.0.0:5051"

when I run the container with an image built by this, it run successfully, but I’m unable to access the application with any of the urls.

the container info shows below
enter image description here

and I tried to access the app on 0.0.0.0:32797, still no luck.

any idea , what have I been doing wrong? this happens particular when I add below in docker file:

 CMD dotnet watch run --urls "http://0.0.0.0:5050;https://0.0.0.0:5051"

any other workarounds/suggestions to achieve "dotnet watch run" inside a container also would do.

PS: here is the docker version info

 Version:           19.03.6-ce
 API version:       1.40
 Go version:        go1.13.4
 Git commit:        369ce74
 Built:             Fri May 29 04:01:26 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.6-ce
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.4
  Git commit:       369ce74
  Built:            Fri May 29 04:01:57 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.2
  GitCommit:        ff48f57fc83a8c44cf4ad5d672424a98ba37ded6
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Source: Dockerfile Questions

LEAVE A COMMENT