-
Notifications
You must be signed in to change notification settings - Fork 166
Description
When using the dotnet runtime container images from Microsoft (mcr.microsoft.com/dotnet/runtime:7.0 and 6.0) the Dockerfile sets an environment variable, ASPNETCORE_URLS, to override the default listening port of ASPNET Core from 5000 to 80 (https://github.com/dotnet/dotnet-docker/blob/main/samples/aspnetapp/README.md#build-an-aspnet-core-image , https://github.com/dotnet/dotnet-docker/blob/a4d4929b8d6b7cdca35af6d71c9d5b79765aadc9/src/runtime-deps/6.0/bullseye-slim/amd64/Dockerfile#L5).
The buildpack for dotnet does not set the environment variable, and because of this, the default port remains 5000 (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-7.0).
This creates a difference in developer experience when developers use the buildpacks vs. when they create a Dockerfile with the standard MCR images. This difference in default behavior may lead to developers failing to host their apps in Cloud Run, if developers are not aware to the change, and keep their deployment configuration the same when switching from Dockerfile to buildpacks or vice versa.
Recommendation:
- Add the ASPNETCORE_URLS for runtime versions <= 7.x, and set the default port to 80.
- For runtime version >= 8.x, the new env variable is ASPNETCORE_HTTP_PORTS and its default value in the MCR images is set to 8080 (https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8#non-root-user , https://github.com/dotnet/dotnet-docker/blob/a4d4929b8d6b7cdca35af6d71c9d5b79765aadc9/src/runtime-deps/8.0/bookworm-slim/amd64/Dockerfile#LL7C24-L7C24).