Skip to content

Fix ASPNETCORE_HTTPS_PORTS using host port instead of container port in Docker HTTPS examples#36824

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-https-ports-examples
Open

Fix ASPNETCORE_HTTPS_PORTS using host port instead of container port in Docker HTTPS examples#36824
Copilot wants to merge 2 commits intomainfrom
copilot/fix-https-ports-examples

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

All docker run examples in the Docker HTTPS docs set ASPNETCORE_HTTPS_PORTS to 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; updated ms.date
  • aspnetcore/security/includes/docker-https6.md — Fixed 3 docker run examples

Before:

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.

docker run --rm -it -p 8000:80 -p 8001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORTS=8001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="<CREDENTIAL_PLACEHOLDER>" -e ASPNETCORE_Kestrel__Certificates__Default__Path=c:\https\aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:C:\https\ --user ContainerAdministrator mcr.microsoft.com/dotnet/samples:aspnetapp

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_PORTS and ASPNETCORE_HTTP_PORTS environment 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_PORTS and ASPNETCORE_HTTP_PORTS should always specify container port numbers (e.g., 80, 443) to match the ports exposed inside the container.
  • Host port numbers in a 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 be 443). This could mislead readers and cause configuration errors.

2. Affected File(s) and Section(s)

  • File to edit:
    aspnetcore/security/docker-https.md

  • Sections affected:
    All CLI code sample sections referencing ASPNETCORE_HTTPS_PORTS (and/or ASPNETCORE_HTTP_PORTS)

    • Example: The initial docker run command shown under the main procedure.
    • Any repeated command examples throughout the document where ports are defined.

3. Recommended Documentation Update

  • Replace all instances where ASPNETCORE_HTTPS_PORTS or ASPNETCORE_HTTP_PORTS is set to a host port number in sample commands.
  • Ensure all Docker examples use the correct container port numbers for these environment variables (typically, ASPNETCORE_HTTPS_PORTS=443, ASPNETCORE_HTTP_PORTS=80 up to the exposed application port inside the container).
  • Add a [!IMPORTANT] note near the first usage explaining the distinction:

    [!IMPORTANT] Use the container port for ASPNETCORE_HTTPS_PORTS and ASPNETCORE_HTTP_PORTS—these must match the port your application listens on inside the container, not the host port mapping.

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:

[!IMPORTANT] The value assigned to ASPNETCORE_HTTPS_PORTS must be the container port (e.g., 443), not the host port (e.g., 8001).

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

📄 File 🔗 Preview link
aspnetcore/security/docker-https.md aspnetcore/security/docker-https

…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
@tdykstra tdykstra marked this pull request as ready for review March 3, 2026 18:42
@tdykstra tdykstra requested a review from wadepickett March 3, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Examples for ASPNETCORE_HTTPS_PORTS and ASPNETCORE_HTTP_PORTS appear to be incorrect

3 participants