Can't access local docker container when using VPN

Viewed 545

I have a couple docker containers running on my local machine (pgadmin, jupyter notebooks etc) and have them mapped to various ports. I can happily navigate to localhost:10100 to get to the pgadmin web interface, for example. The issue is that when I connect to the work VPN I am unable to get to any locally running containers. I get an "ERR_CONNECTION_RESET" error on chrome.

With the VPN on I've tried:

  • localhost:10100 (also tried 127.0.0.1)
  • my-hostname:10100
  • 192.168.0.X:10100 (the wifi interface address)
  • 192.168.19.X:10100 (the VPN TUN interface address)

I can ping any of the above addresses and get a response and can successfully use them when the VPN is disabled. Using PulseVPN, Ubuntu 21.10, and fairly recent docker/docker-compose if that helps.

2 Answers

You can try to run the containers with the host network by adding the flag:

--network host

to the end of each command when you first start the containers. And if that does not work, you can try it with:

--network none

Turns out that are a combination of issues that are causing problems. I haven't found a bullet proof solution yet but here are some breadcrumbs for someone else:

  • The default docker network subnet was overlapping with my work subnet.
  • The VPN route was set to have the lowest cost, therefor all traffic is being routed through it.
  • Changing the default subnet resulted in the containers working, for around 5 minutes. Then the low cost routing was discovered and my traffic went through there instead.

My guess is that I have to fiddle with my network routing so that the docker networks are separated from the work VPN. It's been a decade since my CCNA so I can't remember how to do this off hand...

Related