title: Why does aspnet core start on port 80 from within Docker?
body: <p><strong>TL;DR:</strong> Why does an aspnet core app run on port 80 from within a Docker image, but 5000 outside a docker image. </p>
  
  <p><strong>Elaborate</strong></p>
  
  <p>I went through the aspnet core / docker tutorial found here:
  <a href="https://docs.microsoft.com/en-us/dotnet/core/docker/building-net-docker-images" rel="noreferrer">https://docs.microsoft.com/en-us/dotnet/core/docker/building-net-docker-images</a></p>
  
  <p>Half way through the page, I start the application with the following as prescribed: </p>
  
  <pre><code>dotnet run
  </code></pre>
  
  <p>Among other things, this prints this:</p>
  
  <pre><code>Now Listening on: http://localhost:5000
  </code></pre>
  
  <p>Great. That is what I expected. The next thing in the tutorial is to start the exact same application from within a Docker image. </p>
  
  <pre><code>docker build -t aspnetapp .
  docker run -it --rm -p 5000:80 --name aspnetcore_sample aspnetapp
  </code></pre>
  
  <p>This results in </p>
  
  <pre><code>Now listening on: http://[::]:80
  </code></pre>
  
  <p>Wait. Wat? <strong>Why is the aspnet core app running on port 80?</strong> It was running on port 5000 when I ran it directly from the machine. There were no configuration file changes. </p>
  
  <p>I suspect that it has something to do with the base docker images, but am not yet skilled enough in docker to track this down. </p>