title: Resolve container name in extra_hosts option in docker-compose
body: <p>I need to curl my API from another container.
  Container 1 is called <code>nginx</code>
  Container 2 is called <code>fpm</code></p>
  <p>I need to by able to bash into my <code>fpm</code> container and curl the <code>nginx</code> container.</p>
  <p>Config:</p>
  <pre class="lang-yaml prettyprint-override"><code>#docker-compose.yaml
  services:
   
    nginx:
      build:
        context: .
        dockerfile: ./docker/nginx/Dockerfile
      volumes:
        - ./docker/nginx/conf/dev/api.conf:/etc/nginx/conf.d/default.conf
      ports:
        - 8080:80
      links:
        - fpm
      
      
    fpm:
      build:
        context: .
        dockerfile: ./docker/fpm/Dockerfile
      volumes:
        - .:/var/www/html
        - ./docker/fpm/conf/dev/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
        - ./docker/fpm/conf/dev/api.ini:/usr/local/etc/php/conf.d/api.ini
      env_file:
        - ./docker/mysql/mysql.env
        - ./docker/fpm/conf/dev/fpm.env
      links:
        - mysql
      shm_size: 256M
      extra_hosts:
        - myapi.docker:nginx
  </code></pre>
  <p>My initial thought was to slap it in the <code>extra_hosts</code> option like:</p>
  <pre><code>extra_hosts:
    - myapi.docker:nginx
  </code></pre>
  <p>But docker-compose up fails with:</p>
  <blockquote>
  <p>ERROR: for apiwip_fpm_1  Cannot create container for service fpm: invalid IP address in add-host: &quot;nginx&quot;</p>
  </blockquote>
  <p>I have seen some examples of people using docker's network configuration but it seems over the top to just resolve an address.</p>
  <p>How can I resolve/eval the IP address of the container rather than just passing it literally?</p>