title: Docker EXPOSE vs command line -p option (boot2docker)
body: <p>After spending way too long trying to access my node server running from a docker container within a boot2docker instance I realised the issue came down to a difference between expose and docker run -p.</p>
  
  <p>In my Dockerfile I had EXPOSE 3001, and I could not access this via my host machine.</p>
  
  <p>After running "docker run -p 3001:3001 myappinst myapp" I was able to access the port.</p>
  
  <p>Up until now I thought "docker run -p 3001:3001" was essentially the same as EXPOSE 3001 in the dockerfile. </p>
  
  <p>I noticed however, when running docker ps</p>
  
  <p>I get the following for "EXPOSE":</p>
  
  <p><code>CONTAINER ID        IMAGE                        COMMAND             CREATED             STATUS              PORTS               NAMES
  16341e2b9968        housemation-crawler:latest   "npm start"         2 minutes ago       Up 2 minutes        3001/tcp            housemation-crawler-inst</code></p>
  
  <p>(note: 3001/tcp)</p>
  
  <p>vs the below with <code>docker run -p 3001:3001</code></p>
  
  <p><code>CONTAINER ID        IMAGE                        COMMAND             CREATED             STATUS              PORTS                    NAMES
  0b14f736033c        housemation-crawler:latest   "npm start"         8 seconds ago       Up 2 seconds        0.0.0.0:3001-&gt;3001/tcp   housemation-crawler-inst</code></p>
  
  <p>(0.0.0.0:3001->3001/tcp)</p>
  
  <p>Looks like the latter is doing some kind of port forwarding, whereas the former is just opening up the port? Would that be right?</p>
  
  <p>If I wanted to access a non forwarded exposed port how would I go about doing so? Also, if I wanted to have port forwarding within the dockerfile, what would be the correct syntax?</p>