Multipass is a flexible, powerful tool that can be used for many purposes. In its simplest form, it can be used to quickly create and destroy Ubuntu VMs (instances) on any host machine. Used to a fuller extent, Multipass is a local mini-cloud on your laptop, allowing the testing and development of multi-instance or container-based cloud applications.
This tutorial will give you an understanding of how Multipass works, and the skills you need to use its main features.
- Install Multipass
- Create and use a basic instance
- Create a customised instance
- Manage instances
- Put your instances to use
- Next steps
Multipass is available for Linux, macOs, or Windows. To install it on your OS of choice, please follow the instructions given here. Note: This tutorial demonstrates use on Linux, specifically Ubuntu, but the experience on any OS should be similar.
From the application launcher, let’s start Multipass. In Ubuntu, press the super key and type Multipass, or find Multipass in the Applications panel in the lower left of the desktop.
Once we’ve launched the application, we should see the Multipass tray icon in the upper right section of the screen:
Let’s click on the icon, then on “Open Shell”.
Clicking this button does many things in the background: it creates a new virtual machine (instance), named
primary, with 1GB of RAM, 5GB of disk, and 1 CPU; installs the most recent Ubuntu LTS release on that instance; mounts our $HOME directory in the instance; and opens a shell to the instance, announced by the command prompt
ubuntu@primary. You can see elements of this in the screenshot below.
Let’s test it out! As we just learned, the previous step automatically mounted our $HOME directory in the instance. Let’s use this to share data with our instance. More concretely, let’s create a new folder in our $HOME directory called Multipass_Files:
As you can see, I’ve added a readme file in this shared folder. Let’s check for the folder and read the file from our new instance:
Congratulations, you’ve got your first instance!
This instance is great for when we just need a quick Ubuntu VM, but let’s say we want a more customised instance. Multipass has us covered there too!
When you clicked on Open Shell just now, what happened in the background was the equivalent of the CLI commands
multipass launch –name primary followed by
multipass shell. Open a terminal and try
multipass shell (if you didn’t follow the steps above, you will have to run the
launch command first).
In Multipass, an instance with the name
primary is privileged. For example, it is the default argument of multipass shell. In two terminal instances, check
multipass shell primary and
multipass shell. Both commands should give the same result.
Multipass has a great feature to help us get started creating customised instances. Let’s open a terminal and run the command
multipass find. This shows us a list of all of the images we can launch through Multipass currently.
Let’s launch an instance running Ubuntu 21.10 (“Impish Indri”) by typing the command
multipass launch impish
Now we have an instance running which has been named randomly by Multipass, in my case it is called deluxe-ghoul.
We can check some basic info about our new instance by running the following:
multipass exec deluxe-ghoul -- lsb_release -a
This tells multipass to execute the command
lsb_release -a on the “deluxe-ghoul” instance.
Perhaps after using this instance for a while, we decide what we really need is the latest LTS version of Ubuntu, with a more informative name and a little more memory and disk. We can delete the deluxe-ghoul instance by running
multipass delete deluxe-ghoul
Let’s now launch the type of instance we’re looking for by running this:
multipass launch lts --name ltsInstance --mem 2G --disk 10G --cpus 2
Now let’s confirm this new instance has the specs we’re looking for by running
multipass info ltsInstance
We’ve created and deleted quite a few instances now. Let’s run multipass list to see what instances we currently have.
We have two instances currently running, the primary instance and our LTS machine with customised specs. Our deluxe-ghoul instance is still listed, but its state is “Deleted”. We can recover this instance by running
multipass recover deluxe-ghoul, but for right now let’s delete the instance permanently by running
multipass purge. Running
multipass list again confirms the instance is now permanently deleted:
We’ve now seen a few ways to create, customise, and delete an instance. Now let’s put those instances to work!
Let’s go back to that customised LTS instance we created. Take note of its IP address revealed by
multipass list in the previous step, then run
multipass shell ltsInstance to open a shell in the instance.
From the shell, we can now run:
sudo apt update sudo apt install apache2
Now, let’s open a browser and type in the IP address of the instance into the address bar. We should now see the default Apache homepage.
Just like that, we’ve got a web server running in a Multipass instance!
We can use this web server locally for any kind of local development or testing we like. If however, we want to access this web server from the internet (e.g. from a different computer), we need an instance that is exposed to the external network.
Some environments require a lot of configuration and setup. Multipass Blueprints are instances with a deep level of customization. The Docker Blueprint, for example, is a pre-configured Docker environment with a Portainer container already running. We can launch an instance using the Docker Blueprint by running
multipass launch docker --name docker-dev
Once that’s finished, let’s run
multipass info docker-dev to note down the IP of the new instance.
Let’s take the IP address starting with “10” and paste it into our browser, then add a colon and the portainer default port, 9000, like this: 10.115.5.235:9000. This will take us to the Portainer login page, where we can set a username and password.
From there, let’s select a local docker environment.
From there, we can click into the newly created “local” docker endpoint, navigate to the app templates page, and select NGINX
From the Portainer dashboard, we can see the ports that nginx has available. We can navigate to the IP address of our instance followed by that port number to see that we indeed have nginx running in a docker container inside Multipass!
Congratulations! You now have the skills you need to use Multipass proficiently. There’s more to learn about Multipass and its capabilities - check out our how-to guides for ideas and for help with your project. Our reference page contains definitions of key concepts, a complete CLI command reference, settings options and more.
Let us know what you’re able to get done with Multipass!