docker-compose not adding hostname to /etc/hosts
<p>I'm working on a docker-compose config which should spin up an openvpn container attached to a dnsmasq container. The openvpn server should automatically discover the dnsmasq container and use it as the dns server. Discovery is done by searching for an entry "dnsmasq" in the /etc/hosts file.</p>

<p>I have the following docker-compose.yml file:</p>

<pre><code>version: '2'
services:
  data:
    build: ./
  dnsmasq:
    cap_add:
      - NET_ADMIN
    hostname: dnsmasq
    image: &lt;dnsmasq image&gt;
    ports:
      - 53:53/udp
    restart: always
  openvpn:
    cap_add:
      - NET_ADMIN
    depends_on:
      - data
      - dnsmasq
    image: &lt;openvpn image&gt;
    ports:
      - 1194:1194/udp
    restart: always
    volumes_from:
      - data
</code></pre>

<p>I've specified "dnsmasq" as hostname for the dnsmasq container and expecting it to appear in "/etc/hosts" in the openvpn container. This doesn't seem to happen.</p>

<p>This is a dump from /etc/hosts from within the openvpn container:</p>

<pre><code>openvpn_1  | 127.0.0.1  localhost
openvpn_1  | ::1    localhost ip6-localhost ip6-loopback
openvpn_1  | fe00::0    ip6-localnet
openvpn_1  | ff00::0    ip6-mcastprefix
openvpn_1  | ff02::1    ip6-allnodes
openvpn_1  | ff02::2    ip6-allrouters
openvpn_1  | 172.19.0.4 d44a72f42ef9
</code></pre>

<p>I expect d44a72f42ef9 to be "dnsmasq".</p>

<p>What am I doing wrong?</p>

<p>I'm running docker-compose 1.8.1.</p>