How to build a VPN client as a Docker container
3 min readSep 9, 2022
There is not much to be found online about running a VPN inside Docker. Indeed, I do not believe many out there have thought about it, however leveraging a VPN inside of Docker unlocks a wealth of new possibilities. Here are just a few examples that come to mind, some of which I have used on various projects.
- Secure and encrypted communication of Docker containers to the outside world. This can be a great way to get local resources through an untrusted network.
- Keep Docker containers separate from the local network, while still allowing access to the outside world.
- Connecting remote Docker networks together. As an example, a VPN can securely sync data across multiple datacenters or regions.
- Become cloud and server agnostic. By connecting your containers to a VPN, the containers can be freely moved around environments, and even live on separate clouds, without the need to reconfigure anything. Spin up the containers elsewhere, connect to the VPN, resume operations as normal.
- Take advantage of cloud resources, locked into your private intranet. Perhaps useful for periodic large compute loads. Save money by not paying for servers until they are needed, with nearly the safety of an on premise solution.
- For the devious, punch a hole in a…