Skip to content

Instantly share code, notes, and snippets.

@c-garcia
Created March 15, 2015 18:55
Show Gist options
  • Save c-garcia/12b4d14b9a584164bd53 to your computer and use it in GitHub Desktop.
Save c-garcia/12b4d14b9a584164bd53 to your computer and use it in GitHub Desktop.
Start an OpenVPN Container as a systemd managed service under CoreOS
[Unit]
Description=OpenVPN
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Environment="OVPN_DATA=ovpn-data"
Environment="OVPN_IMAGE=kylemanna/openvpn"
Environment="OVPN_CONTAINER=openvpn_server"
ExecStartPre=-/usr/bin/docker stop ${OVPN_CONTAINER}
ExecStartPre=-/usr/bin/docker rm ${OVPN_CONTAINER}
ExecStartPre=/usr/bin/docker pull ${OVPN_IMAGE}
ExecStart=/usr/bin/docker run --name ${OVPN_CONTAINER} \
--volumes-from ${OVPN_DATA} -p 1194:1194/udp \
--cap-add=NET_ADMIN ${OVPN_IMAGE}
ExecStop=/usr/bin/docker stop ${OVPN_CONTAINER}
[Install]
WantedBy=multi-user.target
@c-garcia
Copy link
Author

A data-only container ovpn-data provides the directory /etc/openvpn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment