Trick a docker containers DNS to resolve a different url I am not sure I know the terminology to describe this correctly, my apologies.

But for a contrived example. Say I have a docker container that runs code that accesses "google.com". But I want all requests that the container sets to "google.com" to actually go to "facebook.com". In other words I want the DNS lookup of one domain name to use another domain when reloving. Is there a way to do this with docker or docker-compose?

My ask is a bit more than this, because I know that often multiple websites are hosted on the same server (same IP), so I need a way for the conversion to happen at the domain name level, not at the IP level.

Thank you
If you want a DNS lookup of one domain to resolve to another one, you have 2 options.


Modify the Container /etc/hosts file. By default any DNS lookup is done there. You schould do that in the Dockerfile. 


Modify /etc/hosts in a Dockerfile


Maintain your own DNS servers with all mapping records. On container runtime just pass the DNS server.


Docker docs


  --dns   The IP address of a DNS server.