How to spin up a 3 nodes docker home lab using Vagrant

As I’m a huge fan of Vagrant, this is the Vagrantfile I’m using to create in 1 run 3 nodes docker environment:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Every Vagrant development environment requires a box. You can search for
# boxes at
BOX_IMAGE = "bento/ubuntu-20.04"

Vagrant.configure("2") do |config|
  if Vagrant.has_plugin?("vagrant-vbguest") then
    config.vbguest.auto_update = false
  config.vagrant.plugins = "vagrant-docker-compose"
  # install docker and docker-compose
  config.vm.provision :docker
  config.vm.provision :docker_compose

  config.vm.box_check_update = false
  (1..NODE_COUNT).each do |i|
    config.vm.define "docker_node#{i}" do |subconfig| = BOX_IMAGE
      subconfig.vm.hostname = "node#{i}" :private_network, ip: "192.168.10.#{i + 100}"
      subconfig.vm.provider "virtualbox" do |vb|   = "docker_node#{i}"


Let’s start the creation of the VMs and measure the execution time (in Windows 10 this time 🙂 ):

PS D:\vagrant\docker> Measure-Command { vagrant up }

Days              : 0
Hours             : 0
Minutes           : 10
Seconds           : 28
Milliseconds      : 173
Ticks             : 6281737909
TotalDays         : 0.00727052998726852
TotalHours        : 0.174492719694444
TotalMinutes      : 10.4695631816667
TotalSeconds      : 628.1737909
TotalMilliseconds : 628173.7909

Now if you want to see the status:

vagrant global-status
id       name    provider   state   directory
00f2ce8  docker_node1 virtualbox running  D:/vagrant/docker
80dda8d  docker_node2 virtualbox running  D:/vagrant/docker
6b7e183  docker_node3 virtualbox running  D:/vagrant/docker

Let’s check the docker version:

PS D:\vagrant\docker> vagrant ssh docker_node1
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-58-generic x86_64)

 * Documentation:
 * Management:
 * Support:

  System information as of Mon 29 Mar 2021 07:09:32 AM UTC

  System load:  0.08              Users logged in:          0
  Usage of /:   3.2% of 61.31GB   IPv4 address for docker0:
  Memory usage: 22%               IPv4 address for eth0:
  Swap usage:   0%                IPv4 address for eth1:
  Processes:    101

This system is built by the Bento project by Chef Software
More information can be found at
vagrant@node1:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:18:20 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:16:15 2021
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
  Version:          0.19.0
  GitCommit:        de40ad0

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.