Unable to resolve private service

I have the following setup:

nginx (docker, public service) handles rate limiting and caching
nodejs (docker, private service) handles actual service calls

I am trying to proxy_pass to the private service internal address.

In nginx the resolver is set to the nameserver ip listed in /etc/resolv.conf.

However the private service address cannot be resolved.

Oddly, in shell, curl is able to resolve the private address.
I installed dnsutils and dig is unable to resolve the private address.

Please advise

On further investigation I notice that nslookup also correctly resolves the using the search domains listed under /etc/resolv.conf. Possibly dig and nginx are not using this information?

Anyway I was able to resolve the problem by parsing both nameserver and search out of /etc/resolv.conf such that I could construct the proper fqdn of the render private service.

TL;DR the private service name won’t work, it needs to be the full internal service fqdn. <service_name>.<search_domain>, then it will work. You can find the search domain with

cat /etc/resolv.conf | grep "search" | awk '{print $2}'