I have a non-containerized nginx instance serving as reverse proxy for containerized as well as non-containerized services.
Since container IPs can change on reboot, I don't want to use them in the nginx config file. I was looking for a simple way to reference the containers. Docker containers can reference each other by container name i.e. DNS lookup of container names gives container's IP. I was looking for something similar but names should be resolvable from host OS.
Constraints:
Solution should work with existing containers. So no docker run ... commands
I have tried mageddo/dns-proxy-server. It is supposed to resolve container names but it does not even after setting the right environment variables.
sudo docker run -d \
--restart unless-stopped \
--name dns-proxy-server \
-p 5380:5380 \
-e MG_REGISTER_CONTAINER_NAMES=true \
--hostname dns.mageddo \
-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
PS: Though nginx is taken as an example, the DNS lookup feature is helpful in many other scenarios. So I am looking for DNS lookup solution and not simply a fix for the nginx issue.