-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Connect back to host machine from within a docker container #36
Comments
Hey @akki-io . Sorry for the delayed response. I skimmed your question when you posted it but then got busy and forgot to follow up. Apologies. The way I always handled services calling each other was using the container name. It is annoying to have different hostnames depending on whether you are on the host or in a container tho. It shouldn't be that hard to get something working tho. I will think on it a bit. Is this something you are still trying to get working? |
First, Thank you for your work on dory! |
To make sure I understand how it would need to work, is the following statement accurate?
This wouldn't allow you to use someservice.docker from two different docker networks, but it would allow you to access any service running on the host machine that are bound to that network interface (in practicality this would be anything bound to 0.0.0.0). |
I need this feature too. Let's say, we have 2 services: serviceA.docker and serviceB.docker. Accessing these services from the host's browser is ok. But when they try to connect to each other, that's the problem. ServiceA.docker cannot resolve the ServiceB.docker address, and vice versa. I can work around the issue by adding an "extra-hosts" in the docker-compose.yml like this: extra_hosts:
- "ServiceB.docker:${HOSTIP}" However, it's cumbersome and require everybody to put their own $HOSTIP in the .env. It'd be great if dory can do that automatically. |
Thanks @ltvan . I have an idea of something we can try. |
I was also investigating this issue in the last couple of days. This works properly with Anyway if you want a fast workaround you can set |
The way dinghy seems to work is that it defines a subnet for its own services (something like 192.168.99.0/24) on the host and the proxy server runs on that. Since the default networking policy is for the containers to see the whole of the host network, and *.docker is proxied via a host in this network, it means the IP address *.docker resolves to is visible and connectible from within the containers. Dory on the other hand resolves to 127.0.0.1 which is always routed to the lo network interface within the containers. However, external_links allows tying dory_dinghy_http_proxy into the local network where it gets an address of its own within the local network. There are two problems with this approach:
Setting the IP to the local IP is a temporary solution at best as that keeps changing from time to time. The best solution would be to open our own local subnet for the proxy (maybe even for dnsmasq) and use that instead of 127.0.0.1. |
Or, as an alternative solution, address: !host (or something like this) could make it so that dory uses the host IP as an address, and would restart dory whenever this IP changes. One thing is for sure, 127.0.0.1 from within the containers will not work, and should not work either. |
I posted a somewhat simple solution to this in another issue- |
Hi,
Dinghy for OS X, has a feature where you can connect back to your host machine from within a docker container.
https://github.com/codekitchen/dinghy#dns
We have multiple microservices running on different networks, when one of my backends tries to communicate with another I get this error -
cURL error 6: Could not resolve host: microservice-2.docker (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
I am using Ubuntu 18.04.
All my coworkers use MacOS with dinghy and it works for them.
Is there a way to make this work with dory?
Thank You
The text was updated successfully, but these errors were encountered: