title: What's the difference between EXPOSE a port from dockerfile with mapping ports when running a container?
body: <p>I know I can EXPOSE a port (e.g. 8888) in dockerfile. With this dockerfile I can build a image, then I run<code>docker run --name container1 -p 8888:8888 image</code>. Via this method I can access port 8888 in the container.</p>
  
  <p>The second way I don't EXPOSE any port from dockerfile. With this dockerfile I can build image2, then I run<code>docker run --name container2 -p 8888:8888 image2</code>.</p>
  
  <p>I wanna ask what is the difference between them ?</p>
  
  <p>I find something strange. </p>
  
  <p>In <code>container1</code> I run <code>jupyter notebook --port 8888</code>. I can both access the <code>port 8888</code> from the host running the container (<code>localhost:8888</code>) and the computer(<code>hostip:8888</code>) in the same local network</p>
  
  <p>In <code>container2</code> I run <code>jupyter notebook --port 8888</code>. I can access the <code>port 8888</code> from the host running the container (<code>localhost:8888</code>), but I can not access the <code>port 8888</code> via <code>hostip:8888</code> from the computer in the same local network.</p>