Build Your Homelab: 16 – Docker In A VM

Homelab 16 - Docker VM

In our previous article, we looked at installing Docker via an LXC Container in our Proxmox Homelab. This article will be an alternative to that article as wo only need one option to run Docker, with this article focussing on running docker in a full Virtual Machine. The choice of which to use is up to each user (check out the differences between LXC and VM)


As we previously looked at what Docker is and how it works, we can summarise it as a way for apps and services to be packed into a container in such a way that it will always run exactly the same. This is due to the app or services’ dependencies, code and executables being contained in the package, meaning it will be the same everywhere we run it. Docker is also a type of virtualisation (as well as containerisation), so yes, it is a lot like Proxmox, although Proxmox has more functionalities and can create full Virtual Machines as we are doing today.


Step 1: Get the Docker VM Command

Although it is possible to create and VM you want, with it’s own Operating system ISO (like we did in our first VM), today we are going to take a shortcut and use our good old helper-scripts.com again. This will simplify the deployment process a lot and make it easier to understand. Firstly, go to helper-scripts.com and search for Docker. You will see two options, one for a VM and one for an LXC. Today we are going for the VM option. Open it. You will see the command we need to run, as well as default credentials and default resource values. We are going to change this default resource values during installation today, but remember that all of these values can be changed after install as well. The only value that is fixed, is the container/VM ID.


Step 2: Set up the Docker VM

Once you have the command copied, open your Proxmox web interface and log in. In the left navigation pane expand Datacenter and select the Proxmox node you want to create the VM on. Once selected, in the middle navigation pane, click Proxmox Shell Button. Paste the command from helper-scripts.com and press enter. The installation process will being and we will go through a couple of steps:

  • The first screen is just an informative screen informing you that you are about to create a new Docker Virtual Machine. Press enter on <Yes>
  • SETTINGS – Being asked if we are going to use Default Settings, select <Advanced> and press enter.
  • VIRTUAL MACHINE ID – We can now select a Virtual Machine ID. ID’s normally go from 100 to 999, so select any ID you want. We are going to add our Docker VM on ID 200 (Same as our LXC Demo, so please select if you are using an MXC or VM). This is one of the few things one cannot edit after creation, so we need to run an ADVANCED SETTINGS install to get the ID we want.
  • MACHINE TYPE – Select the top option i440fx with spacebar and press enter. We will go into more detail about the differences in a future article, but the differences are negligible to be honest.
  • DISK CACHE – Select the top option None (Default) with spacebar and press enter.
  • HOSTNAME – Select the hostname that this VM will identify itself with. The default is docker, and that is fine as is.
  • CPU MODEL – Is this VM going to use virtualisation (option 0 – KVM64) or have full access to the entire machine’s CPU (Option 1 – Host). We like to isolate resources, so go with KVM
  • CORE COUNT – Here we assign the (maximum) CPU cores the installation can use. We are going with 4 so that we can run multiple Docker Containers without problems.
  • RAM – Assign the maximum allocation for RAM Memory. We are going with 8Gb.
  • BRIDGE – The bridge is a network bridge for this VM. Leave as default and press enter.
  • MAC ADDRESS – We need to add a MAC Address for this network Interface. Leave it with the populated value and press enter.
  • VLAN – If you are unsure of this option, just leave it blank and press enter. If you want this VM to run on a separate VLAN, you can enter the VLAN ID here and press enter.
  • MTU SIZE – Just leave the default MTU size (blank) and press enter.
  • START VIRTUAL MACHINE – Do we want to start the VM once completed. Yes we do. Select yes and press enter.
  • ADVANCED SETTINGS COMPLETE – This is just a confirmation that we are ready to create the VM. Select Yes and press Enter.
  • STORAGE POOLS – You will be prompted to select a disk (if you have more than one). Select the disk where you want to add the storage and press enter.

The installation will commence and take a bit of time to complete. Once done, we will be able to change the disk size allocation of this VM, seeing as we did not get that option with the Advanced Settings


Conclusion

We have now gone through the options to get Docker installed on a VM as well as running in an LXC Container. Whichever option you choose, we can now start deploying Docker Containers to our Homelab. This enables us to run a myriad of apps and services at home whoch would normally cost a subscription fee, or risk our data being leaked. Running our services and apps at home ensures privacy and data safety, is free, and above all is a lot of fun! We hope you are enjoying our Build your own homelab series so far, stay tuned for a lot more instalments of the series.