This walkthrough is for creating proper CentOS images for use as Docker "swarm mode" manager or worker nodes. Docker Swarm mode could be seen as an alternative to the robust Kubernetes. To be able to reproduce these node images across your server infrastructure is key for multi-cloud container scalability.
Requirements which need to be running prior to this guide: Linux OS running hypervisor software (KVM, etc)
if you happen to have a graphical desktop for your linux OS, you can run
virt-manager for KVM and it will ease the process greatly.
First thing we need to do is develop the network-scripts on the hypervisor (in this case, a Linux OS running KVM) which will be running our Docker Node guest VMs. For this, we will create a bridge network. Make sure you have some direct route to the host or direct console access to the hypervisor before playing with network-scripts, or be prepared to access the direct console in some way.
To create a new bridge device, navigate to your network scripts directory (for CentOS 7 it's
/etc/sysconfig/network-scripts/). Here we'll create a file called
ifcfg-br0 with the following contents:
Reload configs, etc. Now, in virt-manager you should be able to select a bridge device for your VMs like so:
Start up a new VM which will serve as your Docker Node. Install the OS, etc. Now it's time to setup the guest OS to use an IP address from the Host Bridge network that we just created.
Within your VM (assuming CentOS 7, again), navigate to /etc/sysconfig/network-scripts/
Modify the existing primary network interface (e.g.
ifcfg-etho ) with the following contents:
systemctl restart network now your local ip will be 10.0.0.5 for that docker manager or worker node.
Now, we need to make this reproducible. First step is to comment out the IP address line from the above (i.e. IPADDR=10.0.0.5). Now you need to install the latest docker version to this machine, which should be easy with SCP to move the installer to the guest via local IP address, or maybe you have a nat gateway setup for this internal IP to hit outside to retrieve it.
The reason why we comment out the IPADDR part is so that when we pop up a new VM on the same hypervisor, it won't steal a previous VM's IP address when the cloned VM starts up.
Now your Docker Node VM is ready for freezing. Stop the VM. Clone the VM using virt-manager like so:
...And now you have your universal image for docker swarm mode node. Use this VMDK anywhere, or translate it into a different image format. Whatever your next cloud needs.