Allow adding to internal DNS

My PHP app makes HTTP requests from the server to itself. That is, the PHP container for serving the domain example.com makes requests to example.com (or other domains that I host on my Docker servers).

I would like to be able to add A or CNAME records to Docker’s internal DNS so these requests are resolved to the web proxy I have for incoming requests to the cluster.

Currently, these requests are resolved by my public DNS server (at Cloudflare) for my hosted domains. This works in production but doesn’t work for my staging/testing clusters since the PHP containers making these requests always use the public DNS resolver which only serves the IPs of the public web proxies and not the web proxies in the staging/testing clusters.

I could deploy my own DNS server for DNS name resolution from within the cluster, but it would be a whole lot more convenient to simply be able to add names to the built-in internal DNS server.

So, my feature request is to open up the internal DNS server by adding Docker CLI commands to add/retrieve/remove records in the internal DNS server.

Another feature I would like to see added is for the internal DNS to cache all external DNS responses so that if the external DNS becomes unresponsive, for any reason, the internal DNS would serve up the last cached response.

Since my PHP app makes requests from its container to external websites, my apps won’t fail if only the external DNS is DDoS’d (like happened recently to DynDNS) while the external websites are still reachable (by IP).

Basically, I’m looking to the internal DNS to provide a reliable gateway to external DNS servers so my Docker clusters never fail because of DNS issues (even if my services are restarted or dynamically updated).