This container will auto-build and then auto-run every time you start Docker
The container allows for the host macOS/Windows to access all containers directly using the 172.17.0.0/24
IP addresses. This makes it possible to run for example a client application on your macOS and connect to the cluster that is running in the containers (deployed in Docker using aerolab).
- Ensure no other containers are running (i.e. all are stopped)
- Run the following commands from the terminal / bash shell:
git clone https://github.com/aerospike/aerolab
cd aerolab/tunnel-container-openvpn/build-run
chmod 755 *sh && ./RUNME.sh
- Download Tunnelblick from here, install and start it
- From the task-bar shortcut, click on "VPN Details"
- In Finder/Explorer, navigate to the
aerolab/tunnel-container-openvpn/build-run/keys
directory - Drag-drop the client.conf from finder/explorer to the "Configurations" left-pane of the Tunnelblick window
- Choose either "Only Me" or "All Users", not really important
- Close the Tunnelblick window
- Download OpenVPN Connect from here, install and start it
- Click the Plus button
- Click "Import from file"
- Rename
aerolab/tunnel-container-openvpn/build-run/keys/client.conf
toaerolab/tunnel-container-openvpn/build-run/keys/client.ovpn
- Drag-drop
aerolab/tunnel-container-openvpn/build-run/keys/client.ovpn
into the window and click "Add" - Save and Close the window
Once Docker is started on Windows/macOS, click on the OpenVPN Connect
or Tunnelblick
icon in the taskbar, and click Connect
NOTE: on first run you may get 2 warnings, one about DNS not changing and one about IPs not changing. This is normal as we are not tunneling anything apart from/to Docker traffic. Click on Do not warn ...
on both warning windows and click OK
.
All this does is install openvpn server (with all the bells and whistles of configuration), generate ca/server/client certificates and export the certificates to the host machine. The server configuration has a route to force Docker IP range of 172.17.0.0/16
to go through this VPN tunnel. Tunnelblick and OpenVPN Connect are GUIs for openvpn. Essentially you are just connecting to the openvpn server in a container from the openvpn client on your host machine, allowing a 172.17.0.0/16
route to traverse through.
If you intend to use this tunnel with new networks, here is a high-overview of the process to get that setup:
- run
docker network ls
and find the network in question - run
docker inspect XXX
, replaceingXXX
with the network ID from previous step - run
docker network connect XXX openvpn
to connect networkXXX
to theopenvpn
container - run
docker exec -it openvpn bash
to connect to theopenvpn
container- inside the container edit
/etc/openvpn/server.conf
, find a line statingpush "route 172.17.0.0 255.255.255.0"
and create a new line underneath, adding the correct route inferred from theinspect
command, for example:push "route 172.18.0.0 255.255.0.0"
- type
exit
to exit the container
- inside the container edit
- restart the
openvpn
container withdocker restart openvpn
- reconnect using tunnelblick from your Mac