title: Why does Docker not correctly expose my port when using -P but works with -p 80:80?
body: <p>My Dockerfile contains this:</p>
  
  <pre><code>EXPOSE 80
  </code></pre>
  
  <p>Yet, if I run the image with <code>-P</code> I can't connect to it. Running with <code>-p 80:80</code> works fine.</p>
  
  <pre><code>danny@linux:~$ sudo docker run -d -P dart-test
                 b3277a5483531f6dc23a1c807cf895103fd5333b603c1b4a352e07c9721f1a48
  
  # Can't connect here
  danny@linux:~$ curl http://localhost/
                 curl: (7) Failed to connect to localhost port 80: Connection refused
  
  danny@linux:~$ sudo docker stop b3277
                 b3277
  
  danny@linux:~$ sudo docker run -d -p 80:80 dart-test
                 dfe68699bfb33ce33e8e6e1953ac828b9d31209988df64e2627d9228758438ba
  
  # Connects fine here
  danny@linux:~$ curl http://localhost/
                 Hello, world!
  
  danny@linux:~$ 
  </code></pre>