Even Smaller Docker OpenVPN Container

After minimizing openvpn shown in the Minimal docker openvpn container post I finally got round to going one step further and using buildroot.

Docker shows the image size is now down to 5.598 MB and it only uses ~3MB or ram when running.

Here's how.

First you need a linux machine with the buildroot repo cloned. You'll need the development tools for your platform as well as a few other packages. For a freshly installed Centos 7 system

yum groupinstall "Development Tools"
yum install wget ncurses-devel bc

A couple of things are required before you can compile your root filesystem

run make menuconfig to configure the system and

All other options can be left at default.

Exit the menuconfig system and save your new config

We're now ready to build, run make and go get a cup of coffee or two.

Once complete the build will have produced a tarfile of the root filesystem at output/images/rootfs.tar. Import this into docker and run to make sure it's configured correctly.

docker import - <container name> < output/images/rootfs.tar
docker run -t -i <container name> /bin/sh

At this point we should be ready to go. Assuming opevpn config is in /data/openvpn, the container can either be started with

docker run -d -p 1194:1194 -v /data/openvpn:/etc/openvpn --cap-add=NET_ADMIN <containername> /init.sh

or we can update the container with the CMD required to start it

# dockerfile to update image
FROM <containername>


You can pull this image direct from docker with docker pull aussieade/tinyvpn but where's the fun in that ;-)

Date: 2015-09-14 Wed

Emacs 24.5.1 (Org mode 8.2.10)