From 5615dca4de10f1a79bdc3dd6c3ea3b3036c46e8b Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 29 Oct 2015 20:27:10 -0700 Subject: [PATCH] Run OpenVPN in a container. Because. --- openvpn/Dockerfile | 4 ++++ openvpn/README.md | 30 ++++++++++++++++++++++++++++++ openvpn/docker-compose.yml | 9 +++++++++ 3 files changed, 43 insertions(+) create mode 100644 openvpn/Dockerfile create mode 100644 openvpn/README.md create mode 100644 openvpn/docker-compose.yml diff --git a/openvpn/Dockerfile b/openvpn/Dockerfile new file mode 100644 index 0000000..6df0a12 --- /dev/null +++ b/openvpn/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine +RUN apk update && apk add openvpn +ENTRYPOINT ["openvpn"] +WORKDIR /etc/openvpn diff --git a/openvpn/README.md b/openvpn/README.md new file mode 100644 index 0000000..585df5b --- /dev/null +++ b/openvpn/README.md @@ -0,0 +1,30 @@ +# LMCTVPNFY + +Let Me Containerize That VPN For You + + +## How to use this? + +Drop your OpenVPN configuration file in this directory. + +Let's pretend that it's called `hacktheplanet.ovpn`. + +Then all you have to do is to run: + +``` +docker-compose run vpn hacktheplanet.ovpn +``` + +If you need a password (because your OpenVPN configuration specifies `auth-user-pass`) you will be prompted for it. + +If the VPN server pushes routes and so forth, they will be added to your machine, because the Compose file specifies `net: host` so the container runs within the hosts namespace. + +If you **don't** need to specify a password, you can use `docker-compose run -d vpn hacktheplanet.ovpn` to start the container in the background. + +If you OpenVPN configuration needs extra files (certificates etc) you can drop them in this directory too. + + +## Why? + +Because we're the containerati and we like when things are [neatly arranged in their boxes](https://twitter.com/zooeypeng/status/613053137050439681). + diff --git a/openvpn/docker-compose.yml b/openvpn/docker-compose.yml new file mode 100644 index 0000000..ac32f49 --- /dev/null +++ b/openvpn/docker-compose.yml @@ -0,0 +1,9 @@ +vpn: + build: . + volumes: + - .:/etc/openvpn + net: host + devices: + - /dev/net/tun:/dev/net/tun + cap_add: + - NET_ADMIN