I am looking to do almost the exact same thing as ssh into a server which is connected to a VPN service only now the server is a docker container.
So to summarize, I have a container built with:
- Ubuntu
- node.js
- OpenVpn
At boot time, it starts the OpenVpn client and successfully establishes a VPN connection, thus redirecting all default trafic to the VPN. It also starts a node.js app on port 3000. But because of the VPN connection, I cannot access that port 3000 on the public IPv4 of the host which is expected, at least by default.
Could this be solved with some routing magic inside the docker container?
To add some precisions, the host is a cloud instance i.e. only gets a private IP and gets its public IP through elastic magic...
For now, luckily, I have been using a workaround which is to use the IPv6 public address of the host which doesn't seem to be impacted by the VPN routing. But I feel this is a hack and might stop working eventually.