When deciding which services you wish to run on your NAS, the question of installing apps as normal or using some form of virtualization and containers will likely require answering. Should you fire up virtual machines (VM) or install Docker containers? There's no correct answer as it depends on how you wish to approach service deployment and management. VMs and Docker containers are both excellent routes to take and each has its pros and cons. While I recommend using Docker whenever possible, a VM can also make sense for NAS services. Here's why you should use Docker or VMs for your apps and services.
Linux containers guide: An introduction to containers
Containers have been a buzzword for years... but what are they exactly?
4 It's simply easier
Want to run your own web server? You'll need a few dependencies, which will need to be installed separately. These packages will then need to be managed when updates are rolled out and everything configured to use these packages will share the same resources. With a container, you simply download and install an image that has everything you need to run a web server. It will install everything within the sandboxed instance, so any changes made to the underlying software will affect just this app or service. This makes installing, updating, managing,m and removing apps and the like much more convenient. It's more difficult to break something.
3 Enhanced security through sandboxing
The primary reason for running anything through Docker containers or a virtual machine is security. Containers and VM image instances are much safer than running services and apps directly on your NAS — also known as "bare metal". Containers are similar to virtual machines by running software in an isolated environment on a host system. Unlike a virtual machine, which has its own operating system, containers rely on the underlying host software. Containers share the libraries and binaries of the host operating system and only have the resources and dependencies needed to run the specific application they contain.
Both are considerably more secure than bare metal instances where they directly interact with the host OS. Containers and VMs can also be easily managed, removed, upgraded, and more without affecting one another or anything else on the host system.
2 Run any OS of your choosing
The best part of a virtual machine is the ability to run almost any operating system. Need to fire up Windows to run a service or two? You got it! Debian? That's possible too. You could go full Inception style and run TrueNAS Scale within TrueNAS Scale. Think of a virtual machine like an instance being emulated on your system. It's possible to install Windows 11 through a VM on your NAS and use the Microsoft OS as you would any other PC. You can connect to the internet, install software, run games, and much more. Everything is isolated within the sandbox so there's no risk to other parts of the NAS.
1 Test out new things
Containers and virtual machines make it easy to test out new services, apps, and more without touching the rest of your live environment. Should you wish to make some changes to a specific part of your homelab setup, doing so through virtualization can prove useful in that you can troubleshoot any issues before deployment. This is handy when multiple people rely on your hosted services, such as family members at home.
Use virtual machines and containers
I always recommend using containers or virtual machines over bare metal app installations but have a healthy mix of the two. Virtual machines are great for running dedicated systems and services where specific requirements need to be met, be it a particular OS or some other resource. Containers are great for almost everything else. Using VMs and Docker will let you deploy, manage, update, and even remove apps and services with ease. Improving NAS security through the process is the icing on this sweet cake.
