[SOLVED] Adding custom entries to rancher DNS service

Hello.

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.
172.17.0.1 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> ?
image

Regards

Emmanuel

Hi.

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

“Name” contains an invalid character: .

Is there a solution?

Thanks.

Hi,

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

1 Like

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.