1

I am not sure if this question belongs to stackoverflow. I am using docker containers for my applications. To easily understand my architecture here is some pixel art:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                     Docker Network A                        +
+                                                             +
+   ------------------  Request A      ------------------     +
+   |  Container A   | <-------------- |  Container B   |     +
+   |                |                 |                |     +
+   |  Rest Service  |  Request B      |  Worker with   |     +
+   |                | <-------------- |  VPN Proxy     |     +
+   ------------------                 ------------------     +
+                                                             +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The problem: Container B hast a VPN proxy, which is controlled by my application via python subprocess. Before the app starts the proxy, Container B makes a Request A which is working fine. After that, the app starts the proxy and connects to a location, what is also working fine. But from now on Container B is not able to resolve the hostname of Container A, so all requests are failing.

My question: Is there are way to connect to Container A even with enabled VPN Proxy from Container B?


Update (2020-12-06 11:37):

I found out that the DNS is not working, but access directly via the IP seams working. This is a workaround for now, but not a satisfying solution. If anyone has an idea or advice, this would be awesome.

Max
  • 1,368
  • 4
  • 18
  • 43
  • I believe that if you'll have two network adapters and your vpn supports the "split dns" you'll be able to implement [this solution](https://superuser.com/questions/166555/how-to-use-one-connection-to-the-internet-for-vpn-and-another-for-accessing-othe) – Koko Jumbo Dec 06 '20 at 10:46
  • Thanks for the advice. My VPN doesn't support split tunneling for now. Do you have any other ideas? – Max Dec 06 '20 at 10:54
  • I thought about manipulating the `resolv.conf`, but then again I need to add the IP of `Container A`. – Max Dec 06 '20 at 10:56
  • a. and why is that a problem (about the resolv.conf)? b. why not save the ip prior to running your script? – Koko Jumbo Dec 06 '20 at 11:02
  • IPs of a docker container are not static. So I need to configure the IP for each deployment manually. But I will do this via an environment variable for the application. And since the IP will only change if I delete and create the `Container A`, the effort is not that big. – Max Dec 06 '20 at 11:16
  • you don't have to set the IP manually. you can do dns resolve with the container name – Koko Jumbo Dec 06 '20 at 11:28
  • Okay. I will try this, do you know tutorial? – Max Dec 06 '20 at 11:32
  • example: [How to reach docker containers by name instead of IP address??](https://stackoverflow.com/a/40137914/8979435) – Koko Jumbo Dec 06 '20 at 11:41
  • Okay. Now I understand. That's not working with the proxy enabled. That's the problem. – Max Dec 06 '20 at 13:10
  • that's why I [wrote](https://stackoverflow.com/questions/65166842/docker-container-with-vpn-proxy-not-able-to-connect-to-other-container-in-same-d?noredirect=1#comment115208949_65166842) `why not save the ip prior to running your script` – Koko Jumbo Dec 06 '20 at 14:32
  • That makes sense. Sorry, I was hard of mind. – Max Dec 06 '20 at 17:31

0 Answers0