Chapter 2: Using VirtualBox and Docker Containers for Development
In the previous chapter, we introduced virtualization and containerization. In this chapter, we'll demonstrate how you can use software such as VirtualBox to create virtual machines and we'll use Docker to create containers. The focus of this chapter will be on using these technologies for development on your workstation.
A common problem among developers who work on multiple projects is that, over time, they end up with a lot of software installed on their workstations that they don't currently use. This can be so problematic that the developer might reformat their workstation's hard drive and reinstall the operating system.
Both VirtualBox and Docker containers can be used to resolve this problem. The software you install stays within either the virtual machine's or the container's filesystem and is separate from the workstation's native filesystem. If you delete a virtual machine or container, all the files installed therein are removed – including any applications or development software that was installed.
Another problem that arises for developers is the version of software required to work on a specific project. If the developer is working on one project that uses Node.js v12 and another that uses Node.js v10, they can't really run both projects on the workstation at the same time and switching between versions of Node.js is doable, but ugly. This is a non-issue with virtual machines or containers – you can have one virtual machine with Node.js v12 and another with Node.js v10 and run both virtual machines at the same time. It is similar with two containers, one for each version of Node.js.
Virtualization is very useful when you need to model an entire machine. If your production systems are virtual machines or physical machines, a virtual machine is a good way to emulate that environment. Virtualization is terrific for running a complete alternate operating system on the workstation; that is, you can run Windows 10 in a virtual machine on a macOS or Linux workstation.
In this chapter, we will cover the following topics:
- Host filesystem pollution problem
- Using VirtualBox for virtual machines
- Using Docker containers