Move contents into new folder structure based on primary technology Signed-off-by: Scott Lowe <scott.lowe@scottlowe.org> |
||
|---|---|---|
| .. | ||
| docker-01-setup.sh | ||
| docker-02-setup.sh | ||
| machines.yml | ||
| README.md | ||
| Vagrantfile | ||
Using IPVLAN L3 Interfaces with Docker Containers
These files were created to allow users to use Vagrant (http://www.vagrantup.com) to build an environment for working with Docker containers using IPVLAN L3 interfaces (IPVLAN interfaces running in L3 mode instead of L2 mode). This configuration was tested using Vagrant 1.8.1, VMware Fusion 8.1.0, and version 4.0.5 of the Vagrant VMware plugin.
Contents
-
docker-01-setup.sh: This shell script configures the Docker host VM named "docker-01" with an experimental build of the Docker binary. No changes to this file are necessary.
-
docker-02-setup.sh: This shell script configures the Docker host VM named "docker-02" with an experimental build of the Docker binary. No changes to this file are necessary.
-
machines.yml: This is a YAML file containing the configuration data used by Vagrant when creating and provisioning VMs. This particular Vagrant environment requires four (4) values in this file for each VM:
name(name to be assigned to the box as well as used for hostname),box(the name of the Vagrant box),ram(desired RAM), andvcpu(number of virtual CPUs). -
README.md: The file you're currently reading.
-
Vagrantfile: This file is used by Vagrant to spin up the virtual machines for this environment. No changes need to be made to this document, as all the configuration data is found in other files (like
machines.yml). However, if you are using a virtualization solution other than VMware Fusion, you might need to make changes to this file.
Instructions
These instructions assume you've already installed VMware Fusion, Vagrant, and the Vagrant VMware plugin. Please refer to the documentation for those products for more information on installation or configuration. Note that Internet access is required when using vagrant up to create this environment.
-
Use
vagrant box addto install a 64-bit Ubuntu 15.10 box. I have an Ubuntu 15.10 base box you can use; to use my base box, add the box withvagrant box add slowe/ubuntu-15.10-server-amd64. -
Place the files from the
docker-ipvlan-l3directory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (usinggit clone) or just download the specific files from the thedocker-ipvlan-l3folder. -
If necessary, edit
machines.ymlto specify the name of the Vagrant boxes downloaded in step 1. Editing this file is only necessary if you are not using my base boxes. Please note that a box with a minimum of version 4.2 of the Linux kernel is needed. -
Run
vagrant upto instantiate the learning environment. This will spin up two (2) VMs based on the Vagrant boxes you downloaded in step 1 and specified inmachines.ymlin step 3. Vagrant will also appropriately configure each VM and start the necessary services. Depending on the speed of your system and your Internet connection, this may take a few minutes. -
Use
vagrant ssh docker-01to connect to the Docker host VM. Runsudo docker pull alpine:latestto pull down the latest Alpine image for Docker. -
While still logged into "docker-01", run this command to create a Docker network backed by the IPVLAN driver:
sudo docker network create -d ipvlan \ --subnet=10.1.100.0/24 --gateway=10.1.100.1 \ -o ipvlan_mode=l3 -o parent=ens33 ipvlan100 -
In a separate terminal window, change to the directory where the files from the
docker-ipvlan-l3folder are stored and runvagrant ssh docker-02to log into the second Docker host VM. -
Create the IPVLAN-backed Docker network:
sudo docker network create -d ipvlan \ --subnet=10.1.101.0/24 --gateway=10.1.101.1 \ -o ipvlan_mode=l3 -o parent=ens33 ipvlan101 -
On
docker-01, launch a "target" container to use in verifying connectivity:sudo docker run --net=ipvlan100 --ip=10.1.100.10 -itd alpine /bin/sh -
From
docker-02, usepingto try to connect to the "target" container ondocker-01. The ping should fail. -
Still on
docker-02, add a route to the "target" container:ip route add 10.1.100.10/32 via 192.168.100.100 dev ens33 -
Repeat step #10. The ping should succeed this time.
-
On
docker-02, launch a "target" container to use in verifying connectivity:sudo docker run --net=ipvlan101 --ip=10.1.101.10 -itd alpine /bin/sh -
From
docker-01, try to ping the "target" container you just launched in the previous step. The ping should fail. -
Add a route on
docker-01to the "target" container you launched in step #13:ip route add 10.1.101.10/32 via 192.168.100.101 dev ens33 -
Repeat step #14. The connectivity test should succeed.
You've just deployed IPVLAN L3 interfaces with Docker. Enjoy!