dotnet / dotnet/dotnet-docker

dotnet hot reload not working in container with bind mount

Open
#3,992 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dockerfile
Stars
4.9k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
26

Description

### Describe the Bug

I'm trying to run dotnet container in dev mode (bind mount source code) by running `dotnet watch` inside container bash, but hot reload does not work it just says:
`$ dotnet watch ⌚ File changed: ./Program.cs.`
`$ dotnet watch ⌚ No hot reload changes to apply.`

But if I try running it locally it works fine and updates does get hot reloaded.

### Steps to Reproduce

App.csproj
```csproj


Exe
net6.0
enable

```

Program.cs
```cs
while(true)
{
await Task.Delay(2_000);
Console.WriteLine("Hello, World!");
}
```

and finally the command to run:
`docker run -it --rm -w /app -v "$(pwd):/app" mcr.microsoft.com/dotnet/sdk:6.0 bash -c "dotnet build & dotnet watch"`

When I change the console statement to `Console.WriteLine("Hello, Docker!");` it says this:

![image](https://user-images.githubusercontent.com/14987647/184388227-32aa20f8-96cc-40ea-8b2f-9713a9f66ff6.png)

### Other Information

### Output of `docker version`

Client:
Cloud integration: v1.0.28
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:09:02 2022
OS/Arch: windows/amd64
Context: default
Experimental: true

Server: Docker Desktop 4.11.0 (83626)
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:01:23 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: v1.1.2-0-ga916309
docker-init:
Version: 0.19.0
GitCommit: de40ad0

### Output of `docker info`

Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.8.2)
compose: Docker Compose (Docker Inc., v2.7.0)
extension: Manages Docker extensions (Docker Inc., v0.2.8)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)

Server:
Containers: 5
Running: 0
Paused: 0
Stopped: 5
Images: 15
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: extfs
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.2-0-ga916309
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.102.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 11.69GiB
Name: docker-desktop
ID: VZIN:U7CJ:AUHI:DQZN:J6KE:HNFP:D5X3:N5R3:N3A5:SEF7:CYMQ:V6GH
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.