title: Docker Port Mappings and Hostnames
body: <p>I have got an question, or better to say there are two ones. Both depends on Docker and is related to the understanding of how docker deals with containers hostnames and ports. </p>
  
  <p>Let's say I have two services that are running in a different docker container and exposing port 80 from the container to port 8081 (service1) and port 8082 (service2):</p>
  
  <p>service1 : 8081 : 80
  service2: 8082 : 80</p>
  
  <p>Now it is clear to me that from an host perspective I can access these services by using the exposed ports (<a href="http://localhost:8081" rel="nofollow noreferrer">http://localhost:8081</a> and <a href="http://localhost:8082" rel="nofollow noreferrer">http://localhost:8082</a>). But what if I want to access my services by using the containers like <a href="http://container1" rel="nofollow noreferrer">http://container1</a> and <a href="http://container2" rel="nofollow noreferrer">http://container2</a>? What I have to do to realize this szenario meaning:</p>
  
  <ul>
  <li>how might be the port forwarding</li>
  <li>and how I know the exact hostname so I could resolve the containers hostnames from the docker host machine?</li>
  </ul>
  
  <p>Thanks for help!</p>