Is there a config to change the behaviour of the name resolver of Amazon Linux 2 to not ignore entry about localhost
subdomains ?
i.e currently it does :
docker run -it amazonlinux:2023 /bin/bash -c "echo '172.4.0.2 app.localhost' >> /etc/hosts ; curl -v app.localhost "
* Trying 127.0.0.1:80...
while centos (or ubuntu) works "as expected"
docker run -it centos /bin/bash -c "echo '172.4.0.2 app.localhost' >> /etc/hosts ; curl -v app.localhost "
* Trying 172.4.0.2...
Why do I need this
On our local development environment I have 2 docker
- one with our main application, running on a Amazon Linux 2 (to be as close as possible to production environment)
- one containing a mock of an other HTTP service
as the mock needs to be accessed both by the main application from the backend, but also by the frontend, having the mock being named app.localhost allows
- on the frontend to use the fact that we don't need to create extra /etc/hosts entry
- both frontend and backend use the same name/env variable containing the hostname, which is also the case in production
What I've checked
- both have the same `/etc/host.conf config
getent hosts app.localhost
for both returns172.4.0.2
- the glic version of Amazon Linux 2 is
2.34
and centos 2.28, and ubuntu 2.35 , so at least it's not a behaviour change in glibc - change the
/etc/nsswitch.conf
to match the one of my ubuntu
passwd: files systemd
group: files systemd
shadow: files
gshadow: files
hosts: files mdns4_minimal [NOTFOUND=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
Is there other places that may affect how localhost names are resolved ?