[SOLVED] Adding custom entries to rancher DNS service


I’m struggling with some specific problem I couldn’t find solution by myself.
I need to tell to all of my containers in stacks to resolve certain hostname to specific IP address e.g. hostname.domain

Normally I would edit file /etc/hosts within the container, but I’m looking for automated solution for my entire environment.

Is it possible to add custom entries into rancher DNS service? Or to tell rancher DNS server to use entries from /etc/hosts file from rancher host machine? My rancher host is running in AWS so i’m not able to modify DNS used in this virtual machine.

Thank you for your reply.
Best regards

Michal Behúň

Hi Michal

What about adding to your stack an external service pointing to that IP and using <external_service_name>.<stack_name> ?




I already tried, it only allow me to use name without "."
I need to bind address to “service.hostname.domain.com” but this gave me an error

“Name” contains an invalid character: .

Is there a solution?



While this will not work using Add Service → Add External Service (which is really annoying but not going to change), you can do it within a service definition.

First you create the External Service as @Emmanuel outlines, and then within your service definition add a Service Link

This will accept . in the name and result in (in my example) enum.example.com resolving to the IP of the external service.

Hope this helps.

-Barry Flanagan


Thank you very much @flantel. Your solution worked like a charm. I somehow felt that solution should be super easy. But since I’m just a begginer in ranhcer and docker, this saved me a lot of time.