devcontainers / templates

Repository for Dev Container Templates that are managed by Dev Container spec maintainers. See https://github.com/devcontainers/template-starter to create your own!
https://containers.dev/templates
MIT License
990 stars 254 forks source link

dotnet-postgres - webapi "dotnet watch run" Failed to determine the https port for redirect. #110

Open shanemwebster opened 1 year ago

shanemwebster commented 1 year ago

When running "dotnet watch run" from the container terminal inside of a dotnet7 webapi template you get the below error.

How to reproduce

  1. Create new dev container for dotnet-postgres with no additional features.
  2. Open dev container terminal
  3. run dotnet new webapi -o testapi
  4. cd testapi
  5. run dotnet watch run
  6. Open browser and go to listed localhost address

You will then see the following error warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect.

Base OS: Arch Linux

Docker Info: Client: Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc., 0.9.1) compose: Docker Compose (Docker Inc., 2.14.2) scan: Docker Scan (Docker Inc., v0.1.0-271-g6c852fac62)

Server: Containers: 2 Running: 2 Paused: 0 Stopped: 0 Images: 8 Server Version: 20.10.22 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: false userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323.m runc version: init version: de40ad0 Security Options: apparmor seccomp Profile: default cgroupns Kernel Version: 6.1.7-1-MANJARO Operating System: Manjaro Linux OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 23.26GiB Name: shane-laptop ID: W55L:GLVC:D6X5:WTRI:4UFT:WNKE:QLM3:763G:3CJW:JEEP:H2DE:6TKI Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

samruddhikhandale commented 1 year ago

Hi 👋

I was able to reproduce the same errors.

Hence, I tried to use another .NET project - webapp (created with dotnet new webapp -o test2). The dotnet watch run worked fine and the port forwarded URL also worked this time.

I suspect if the issue is with the wepapi project and not with the dev container/template. I think, it would be great to create an issue on the dotnet repo.

Let me know your thoughts.