How to build a VPN client as a Docker container

Ben Lobaugh
3 min readSep 9, 2022
Photo by Sasun Bughdaryan on Unsplash

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…



Ben Lobaugh

Director of Engineering at Mindsize. 20+ year technology veteran. Providing leadership insights, mentorship, and coaching to new and existing leaders.