dns - Routing TLD in docker image to 127.0.0.1 -
foreword
my rails app cares hostname. example when request comes domain-a.dev
behaves differently when request comes domain-b.dev
. want test behaviour , therefore have routed complete *.dev
tld 127.0.0.1
on local machine, can set domain of server in tests want uses local machine tests server.
this necessary because tests use selenium
, launches external browser , browses domain-a.dev
or domain-b.dev
. cannot overwrite request.hostname
(or so) in tests, because has no effect on external browser.
now want use docker image tests, not have configure test environment on multiple servers start docker image. works far *.dev
resolving.
afaik docker uses hosts nameserver or google nameserver default (https://docs.docker.com/articles/networking/#dns), mean change host's dns accomplish goal don't want.
i want build docker image, special tld, example dev
, routes 127.0.0.1
, without touching docker host.
this means running docker image, example domain.dev
resolved 127.0.0.1
inside container. (not domain.dev
, every *.dev
domain.). other tlds should work usual.
an idea have start dnsmasq
inside container, configured resolve *.dev
127.0.0.1
, forward rest usual nameserver. new docker , have no idea if complicated or how accomplished.
another idea might overwrite /etc/hosts
in container fixed entries special domains. mean have update docker container in case want resolve new domains 127.0.0.1
, drawback if domains change often.
what docker experts say?
i worked around using http://xip.io/
by using urls sub.127.0.0.1.xip.io
can connect local machine. app has know 127.0.0.1.xip.io
treated "top level domain", , sub
domain name without tld. (in ruby on rails app can done adjusting config.action_dispatch.tld_length = 6
example).
Comments
Post a Comment