docker-compose not adding hostname to /etc/hosts
Older versions of linking in docker worked by adding to /etc/hosts. It's probable your system was setup initially under this paradigm where the way to retrieve the container resolution was built into /etc/hosts.
Newer versions of docker however do not require this. They automatically allow service name resolution, as long as a container is on the same network. So you can access it via:
http://dnsmasq:port
First you need to add a "links" key to your docker-compose.yml
like so:
services: dnsmasq: ... openvpn: ... links: - dnsmasq
The DNS resolution for for this hostname is not handled through /etc/hosts
but rather the Docker Embedded DNS. You can query it using normal DNS tools like so:
$ getent hosts dnsmasq$ nslookup dnsmasq$ dig dnsmasq A$ # etc...
Apparently, the hosts files doesnt get update. The host "dnsmasq" is just available using some other different mechanism. This can be verified using:
ping -c1 dnsmasq