title: Local hostnames for Docker containers
body: <p>Beginner Docker question here,</p>
  
  <p>So I have a development environment in which I'm running a modular app, it is working using Docker Compose to run 3 containers: server, client, database.</p>
  
  <p>The <code>docker-compose.yml</code> looks like this:</p>
  
  <pre><code>#############################
  # Server
  #############################
  server:
    container_name: server
    domainname: server.dev
    hostname: server
    build: ./server
    working_dir: /app
    ports:
      - "3000:3000"
    volumes:
      - ./server:/app
    links:
      - database
  
  #############################
  # Client
  #############################
  client:
    container_name: client
    domainname: client.dev
    hostname: client
    image: php:5.6-apache
    ports:
       - "80:80"
    volumes:
     - ./client:/var/www/html
  
  #############################
  # Database
  #############################
  database:
    container_name: database
    domainname: database.dev
    hostname: database
    image: postgres:9.4
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
      - POSTGRES_DB=dbdev
      - PG_TRUST_LOCALNET=true
    ports:
      - "5432:5432"
    volumes:
      - ./database/scripts:/docker-entrypoint-initdb.d # init scripts
  </code></pre>
  
  <p>You can see I'm assigning a .dev domainname to each one, this works fine to see one machine from another one (Docker internal network), for example here I'm pinging <code>server.dev</code> from <code>client.dev</code>'s CLI:</p>
  
  <pre><code>    root@client:/var/www/html# ping server.dev
      PING server.dev (127.0.53.53): 56 data bytes
      64 bytes from 127.0.53.53: icmp_seq=0 ttl=64 time=0.036 ms
  </code></pre>
  
  <p><strong>This works great internally, but not on my host OS network.</strong></p>
  
  <p>For convenience, I would like to assigns domains in MY local network, not the Docker containers network so that I can for example type: client.dev on my browsers URL and load the Docker container.</p>
  
  <p>Right now, I can only access if I use the Docker IP, which is dynamic:</p>
  
  <pre><code>client: 192.168.99.100:80
  server: 192.168.99.100:3000
  database: 192.168.99.100:5432
  </code></pre>
  
  <p>Is there an automated/convenient way to do this that doesn't involve me manually adding the IP to my /etc/hosts file ?</p>
  
  <p>BTW I'm on OSX if that has any relevance.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit:</strong> I found this Github issue which seems to be related: <a href="https://github.com/docker/docker/issues/2335">https://github.com/docker/docker/issues/2335</a></p>
  
  <p>As far as I understood, they seem to say that it is something that is not available outside of the box and they suggest external tools like: </p>
  
  <ul>
  <li><a href="https://github.com/jpetazzo/pipework">https://github.com/jpetazzo/pipework</a></li>
  <li><a href="https://github.com/bnfinet/docker-dns">https://github.com/bnfinet/docker-dns</a></li>
  <li><a href="https://github.com/gliderlabs/resolvable">https://github.com/gliderlabs/resolvable</a></li>
  </ul>
  
  <p>Is that correct? And if so, which one should I go for in my particular scenario?</p>