title: Unable to access Docker application from browser
body: <p>I have a .NET Core 2.1 API which, when run via Visual Studio in Windows, receives a HTTP GET from the browser and successfully returns data from a MySQL DB.</p>
  
  <p>I've been trying to add the API to a Docker container (inside Ubuntu) - this builds, but I can't access the API from the browser:</p>
  
  <p><a href="https://i.stack.imgur.com/8WpMI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8WpMI.png" alt="Firefox"></a></p>
  
  <p><strong>What I've tried</strong>:</p>
  
  <ul>
  <li>Checking available ports. Here's the relevant output:</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/gArX3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gArX3.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>Connecting using a different browser: In Chromium, it says 'This site can't be reached: <strong>localhost</strong> unexpectedly closed the connection.'</li>
  <li>Testing unused ports in the browser to see if this returns a different message - for Firefox, unused ports return 'Unable to connect' instead of 'Secure connection Failed', and in Chromium they return 'localhost refused to connect.' instead of 'localhost unexpectedly closed the connection.'</li>
  <li>In Firefox, configuring 'security.tls.insecure_fallback_hosts' to 'localhost'.</li>
  <li>Double-checking that ports are mapped correctly in docker-compose.yml - under 'ports' for the relevant container, 44329 is mapped to 44329.</li>
  <li>Running a DB query when the API starts and logging the result: this is successful. I run <code>docker-compose up</code>, the API starts, connects to the DB container, and it logs the result of an SQL query to a text file. So the problem is unlikely to be anything to do with the database.</li>
  <li>Logging GET requests: Inside Windows, the GET requests are successfully logged, but in the Ubuntu Docker container, they're not.</li>
  </ul>
  
  <p>This might be relevant: In Windows, the API only works properly if you start it from Visual Studio. If you execute <code>dotnet webapi.dll</code>, you get this output</p>
  
  <pre><code>...\netcoreapp2.1&gt;dotnet webapi.dll
  ...
  Now listening on: http://localhost:5000
  Now listening on: https://localhost:5001
  Application started. Press Ctrl+C to shut down.
  </code></pre>
  
  <p>So here it's not running on 44329; instead it's accessible via 5001 in the browser, where you get this message which is not chill at all: 
  <a href="https://i.stack.imgur.com/JM8gj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JM8gj.png" alt="enter image description here"></a>
  Clicking 'ADVANCED' allows you to continue to the API.</p>
  
  <ul>
  <li>So I've also tried connecting via 5001 in Ubuntu without luck.</li>
  </ul>
  
  <p>Here's the output from 'docker-compose up':</p>
  
  <pre><code>matt@Matt-Ubuntu:~/docker2$ docker-compose up
  Starting docker2_mysql_1 ... done
  Starting docker2_dbmodelmapper_1 ... done
  Attaching to docker2_mysql_1, docker2_dbmodelmapper_1
  ... (mysql stuff) ...
  dbmodelmapper_1  | Hosting environment: Production
  dbmodelmapper_1  | Content root path: /app
  dbmodelmapper_1  | Now listening on: http://[::]:80
  dbmodelmapper_1  | Application started. Press Ctrl+C to shut down.
  </code></pre>
  
  <ul>
  <li><p>Seeing the port 80, I've tried connecting to that, without success.</p></li>
  <li><p>The relevant container as shown by <code>docker ps</code> is:</p>
  
  <p><a href="https://i.stack.imgur.com/x8R5N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x8R5N.png" alt="enter image description here"></a></p></li>
  </ul>
  
  <p>What kind of issue am I looking at here?</p>