title: Docker Compose: services unable to resolve each other's hostnames
body: <p>Consider a simple Docker Compose file.</p>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.0&quot;
  
  networks:
    basic:
  
  services:
  
    srv:
      image: alpine
      networks:
        basic:
            aliases:
              - server.nowhere.fake
      domainname: server.nowhere.fake
      entrypoint: tail -f
  
    cli:
      image: alpine
      networks:
        basic:
            aliases:
              - client.nowhere.fake
      domainname: client.nowhere.fake
      entrypoint: nslookup server.nowhere.fake
  
  </code></pre>
  <p>Successful DNS resolutions is easily shown.</p>
  <pre><code>$ docker-compose up
  Creating network &quot;tmp_basic&quot; with the default driver
  Creating tmp_srv_1 ... done
  Creating tmp_cli_1 ... done
  Attaching to tmp_srv_1, tmp_cli_1
  cli_1  | Server:        127.0.0.11
  cli_1  | Address:   127.0.0.11:53
  cli_1  | 
  cli_1  | Non-authoritative answer:
  cli_1  | 
  cli_1  | Non-authoritative answer:
  cli_1  | Name:  server.nowhere.fake
  cli_1  | Address: 192.168.192.2
  cli_1  | 
  tmp_cli_1 exited with code 0
  </code></pre>
  <p>However, a more manual approach yields less productive results.</p>
  <pre><code>$ docker-compose run -d srv
  Creating network &quot;tmp_basic&quot; with the default driver
  tmp_srv_run_8ff7ac6b8cc8
  $ 
  $ docker-compose run cli
  Server:     127.0.0.11
  Address:    127.0.0.11:53
  
  ** server can't find server.nowhere.fake: NXDOMAIN
  
  ** server can't find server.nowhere.fake: NXDOMAIN
  </code></pre>
  <p>In fact, it seems irrelevant whether the server is running, as its address is not resolved.</p>
  <p>For some scenarios, finer control is required, as with using <code>run</code> for single services instead of <code>up</code> for all, such as in cases of terminal interaction.</p>
  <p>In my case, I am seeking to test terminal I/O using a tool that simulates a human, by providing prescribed responses to various prompts.</p>
  <p>Why does the lookup fail when the container is started in a separate operation? What solution is available?</p>