Fix ASPNETCORE_HTTPS_PORTS using host port instead of container port in Docker HTTPS examples#36824
Open
Fix ASPNETCORE_HTTPS_PORTS using host port instead of container port in Docker HTTPS examples#36824
Conversation
…host port 8001 Co-authored-by: tdykstra <1569635+tdykstra@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix examples for ASPNETCORE_HTTPS_PORTS and ASPNETCORE_HTTP_PORTS
Fix ASPNETCORE_HTTPS_PORTS using host port instead of container port in Docker HTTPS examples
Mar 3, 2026
meaghanlewis
approved these changes
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All
docker runexamples in the Docker HTTPS docs setASPNETCORE_HTTPS_PORTSto the host-side port (8001) rather than the container port (443). This is incorrect — the variable tells Kestrel which port to listen on inside the container, not what the host maps to.Changes
aspnetcore/security/docker-https.md— Fixed 3 docker run examples; updatedms.dateaspnetcore/security/includes/docker-https6.md— Fixed 3 docker run examplesBefore:
docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_HTTPS_PORTS=8001 ...After:
docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_HTTPS_PORTS=443 ...Original prompt
This section details on the original issue you should resolve
<issue_title>Examples for ASPNETCORE_HTTPS_PORTS and ASPNETCORE_HTTP_PORTS appear to be incorrect</issue_title>
<issue_description>### Description
Examples on this page appear to use ASPNETCORE_HTTP_PORTS and ASPNETCORE_HTTPS_PORTS incorrectly and are inconsistent with similar examples on https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port (which appear correct).
e.g. in the following example, ASPNETCORE_HTTPS_PORTS is 8001, but this is the host port, not the container port. The same error is present in all examples in this page.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/security/docker-https?view=aspnetcore-8.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/docker-https.md
Document ID
2f32c7c3-8667-0e88-495b-c0c888572964
Article author
@Rick-Anderson
Associated WorkItem - 362958</issue_description>
Comments on the Issue (you are @copilot in this section)
@wadepickett AI analysis test run by wadepickett Prompt: verify-issue-set-course-of-action_v.05.md Model: github-copilot (2024-06) -------Issue Analysis: Examples for ASPNETCORE_HTTPS_PORTS and ASPNETCORE_HTTP_PORTS appear to be incorrect
Issue Summary
This is a valid issue.
1. Issue Context and Validation
The user reports that examples on the article Host ASP.NET Core in a Docker container with HTTPS incorrectly use the
ASPNETCORE_HTTPS_PORTSandASPNETCORE_HTTP_PORTSenvironment variables. Specifically, container startup commands set these variables to host port values instead of the correct container port values. The user's citation references more accurate usage found in the .NET containers compatibility documentation.Based on both the docs and .NET container runtime behavior:
ASPNETCORE_HTTPS_PORTSandASPNETCORE_HTTP_PORTSshould always specify container port numbers (e.g., 80, 443) to match the ports exposed inside the container.docker run -p ...command are mapped externally and are not relevant to these environment variables.Validation:
Review of the published doc confirms all sample commands incorrectly use host ports (e.g.,
ASPNETCORE_HTTPS_PORTS=8001) instead of the correct container port (should be443). This could mislead readers and cause configuration errors.2. Affected File(s) and Section(s)
File to edit:
aspnetcore/security/docker-https.mdSections affected:
All CLI code sample sections referencing
ASPNETCORE_HTTPS_PORTS(and/orASPNETCORE_HTTP_PORTS)docker runcommand shown under the main procedure.3. Recommended Documentation Update
ASPNETCORE_HTTPS_PORTSorASPNETCORE_HTTP_PORTSis set to a host port number in sample commands.ASPNETCORE_HTTPS_PORTS=443,ASPNETCORE_HTTP_PORTS=80up to the exposed application port inside the container).[!IMPORTANT]note near the first usage explaining the distinction:4. Example Code or CLI Snippets (if applicable)
Correction Example
Current (incorrect):
docker run --rm -it -p 8000:80 -p 8001:443 \ -e ASPNETCORE_URLS="https://+;http://+" \ -e ASPNETCORE_HTTPS_PORTS=8001 \ ...Recommended (correct):
docker run --rm -it -p 8000:80 -p 8001:443 \ -e ASPNETCORE_URLS="https://+;http://+" \ -e ASPNETCORE_HTTPS_PORTS=443 \ ...Add the following explanatory note:
5. Copi...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews