It seems this is related to your compose file version:
If you’re using a version 2 Compose file, no
/etc/hosts
entries will be created. This is not a bug. Version 2 files make use of Docker networking, which uses DNS instead of/etc/hosts
to resolve hostnames.