Ubuntu Multipass

Introduction

Ubuntu Multipass is used to quicky launch and manage Linux virtual machines on any workstation. It is available for Linux, MacOS and Windows. From developer’s perspective it is an interesting alternative to Docker or VirtualBox. For me, it feels easier and simpler to use. It has become indispensable tool for keeping my workstation clean. It helps with testing and deployment of my software.

Flame Wars Disclaimer

This article is not about cloud, deployment strategies, Kubernetes, helm, swarms, AWS vs Azure and alike. It’s about using virtual machines to help software developer and devops engineer with daily work.

How does Multipass work?

As simple as this:

# Create and launch new virtual machine named "backend"
multipass launch --name backend

# Check how it's doing
multipass info backend

# Run single command on the machine
multipass exec backend -- systemctl restart apache

# Launch interactive shell session with the machine
multipass shell backend

# List all instances
multipass list

# Reboot
multipass restart backend

# Dispose of the instance
multipass delete backend

There are few more commands such as mount for mounting directories or transfer for copying files. Detailed documentation is available at https://multipass.run/docs.

What can I do with Multipass?

We agree that virtual machines and containers are most useful tools in developer’s toolbelt. By installing third-party software on isolated environments we keep our workstations clean and healthy. By using clean environments for testing and deployments we’re less vulnerable to “It Works on My Machine” syndrome.

We differ on how to best achieve this. We use Docker, VMWare, VirtualBox, cheap VPS, disposable instances in the cloud and many other solutions.

Multipass virtual machines are fully functional Ubuntu LTS instances. Everything that can be done with Ubuntu Linux server, can be done with Multipass instances. We can run software in isolation from your workstation. We can safely play with alternative versions. We can launch multiple micro-instances running automated integration tests. We can test deployment scripts locally, before running them on higher environments. Possibilities are endless.

What are the benefits of Multipass?

How does Multipass compare to Docker, from developer’s perspective? Your mileage might vary, but for me the following benefits are important:

Multipass instance runs full uncompromised Ubuntu LTS

Everything is ready out of the box, beginning with nano and curl. All my familiar Linux tools are either there or one apt install away. I can start using the newly launched instance right away, using the concepts, tools and commands I already know.

Here’s why this is important. Developer’s brain already runs on full capacity. Each time I need to learn another command, another precious childhood memory has to make room and goes down the drain, forever lost. I read that recently on The Oatmeal so it must be true ;-)

Multipass instance is connected

Immediately after launching the instance can access LAN and WAN. It is open for connections, without additional configuration. There is no need to manually configure virtual networks or map ports.

Multipass instance is persistent

Docker containers are disposable by design. Data shouldn’t be kept on them. We use shared volumes instead. This comes with limitations. For crucial security reasons, Docker allows mounting volumes only once, when container is created. But these otherwise important considerations aren’t relevant on my development machine.

Multipass has mount command for mounting host folders into the instance. This can be done at any time: before starting the instance but also while it is already running.

Additionally, the primary instance mounts my home folder as ~/Home by default, so I can access my files instantly.

Multipass instance management is easy

Command syntax and options are few, and easy to memorize. With ability to execute commands and transfer files we can easily write scripts to fully automate software installation, integration tests, deployment tasks etc.

There is even UI for that

After installing Multipass on my PopOS! Linux box I saw the following in the top bar:

Multipass Gnome Extension

How nice!

I want it, I want it, where can I get it?!

Multipass can be used on Linux, MacOS and Windows.

On Linux, Multipass is best installed with snap. On Ubuntu-based distributions chances are snap is already there, so simply run

sudo snap install multipass

and Multipass is ready to go. Otherwise install snap daemon first, using package manager of choice.

To install it on other platforms download proper installation package from https://multipass.run/.

Remarks

Multipass instances might not start if another VM software is running, such as Oracle VirtualBox. Simply stop VirtualBox and try again.

Enjoy!