title: Understanding ports and links in docker compose
body: <p>From my understanding of docker compose / fig, creating a link between two services/images is one main reason if you do not want to exposes ports to others.</p>
  
  <p>like here <strong>db</strong> does not expose any ports and is only linked:</p>
  
  <pre><code>web:
    build: .
    links:
     - db
    ports:
     - "8000:8000"   
  db:
    image: postgres
  </code></pre>
  
  <p>Does <strong>web</strong> thinks <strong>db</strong> runs on its localhost? Would i connect from a script/program in <strong>web</strong> to localhost:5432 (standard port from postgresql) to get a database connection? </p>
  
  <p>And if this is correct, how can you change port 5432 to 6432, without exposing?
  would i just run postgresql on a different port?</p>
  
  <p>Update:</p>
  
  <p>useful links after some input:</p>
  
  <p><a href="http://docs.docker.com/userguide/dockerlinks/">http://docs.docker.com/userguide/dockerlinks/</a></p>
  
  <p><a href="https://docs.docker.com/compose/yml/#links">https://docs.docker.com/compose/yml/#links</a></p>