title: Kubernetes - container communication within a pod using names instead of 'localhost'?
body: <p>From the kubernetes <a href="http://kubernetes.io/docs/user-guide/pods/" rel="noreferrer">docs</a>: </p>
  
  <blockquote>
    <p>The applications in a pod all use the same network namespace (same IP and port space), and can thus “<em>find</em>” each other and communicate using localhost.</p>
  </blockquote>
  
  <p><em>Is it possible to use some container specific names instead of <code>locahost</code>?</em> </p>
  
  <p>For example, with <code>docker-compose up</code>, you use <em>name of the service</em> to communicate. <a href="https://docs.docker.com/compose/networking/" rel="noreferrer">[docs]</a></p>
  
  <p>So, if my <strong>docker-compose.yml</strong> file is</p>
  
  <pre><code>version: '2'
  services:
    web:
      build: .
      ports:
        - "8000:8000"
    srv:
      build: .
      ports:
        - "3000:3000"
  </code></pre>
  
  <p>Then I access <code>srv</code> from within <code>web</code> by calling <code>http://srv:3000/</code>, <strong>not</strong> <code>http://localhost:3000</code></p>
  
  <p>How can I achieve the same behaviour in kubernetes? Any way to specify what name to use in pods' yaml configuration?</p>