Question docker host know container ip and hostname

See this answer, this make possible to run a container and solve it by hostname at host machine, it would be helpful for development

docker run --rm --hostname dns.mageddo --name dns-proxy-server -p 5380:5380 \
  -v /opt/dns-proxy-server/conf:/app/conf \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /etc/resolv.conf:/etc/resolv.conf \
  defreitas/dns-proxy-server

Running a test container

docker run --hostname nginx.dev.intranet nginx

Testing it

ping nginx.dev.intranet
PING nginx.dev.intranet (172.17.0.5) 56(84) bytes of data.
64 bytes from 172.17.0.5: icmp_seq=1 ttl=64 time=0.099 ms
64 bytes from 172.17.0.5: icmp_seq=2 ttl=64 time=0.069 ms
1 Like