Docker container internal vs external dns resolution issue using Traefik

谁说我不能喝 提交于 2019-12-06 15:08:48

For full details on how to solve this: https://medium.com/@williamhayes/local-dev-on-docker-fun-with-dns-85ca7d701f0a

Basically - DNSMasq was working great, Mac Docker Desktop DNS mapping was working great. I could query for my service domain name (e.g. service1.test) dig service1.test1 and get back 127.0.0.1 which is exactly what I set up in DNSMasq. So my domain name was returning the correct IP address for my host. Except - I was getting this inside my container - so 127.0.0.1 was referring to my container environment.

Running the following command on the Mac host level in a terminal:

sudo ifconfig lo0 alias 10.254.254.254

added an alias for 127.0.0.1 that I could use in DNSMasq instead of 127.0.0.1 that would still map to my localhost but it would also work for routing from my docker containers.

Now I can use local domains on my Mac for local development in Docker and get to my containers from my host AND via inter-container requests.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!