[Part 1]: Multipass is really great for Devs

Pushpa Raj B.
3 min readJan 2, 2021

What is multipass?

Multipass is a tool to launch and manage VMs on Windows, Mac, and Linux that simulates a cloud environment with support for cloud-init. Get Ubuntu on-demand with clean integration to your IDE and version control on your native platform.

This lets you quickly spin a new Ubuntu VM on your machine, test something on it, and stop/delete it when it is not required.

We will try to create our own server and host production rails application with passenger and Nginx along with action cable in next post.

In this post, we will install multipass and look at some of the commands that multipass supports:

Setup multipass

We will need a snap package manager to install multipass if you are on a Linux machine.

If you are in Mac or Windows, you can download installer package and install multipass like other applications
- https://github.com/canonical/multipass/releases — download latest release from here for Mac or windows.

Follow the below commands to install multipass in your Linux machine

# Make sure you already have snap package manager installed
sudo apt update
sudo apt install snap
# install multipass using snap
sudo snap install --classic multipass
# Create and start an Ubuntu instance
multipass launch --name ubuntu-lts
# Find other supported versions by running
multipass find
# and to let's say you want to run daily build of ubuntu then
multipass launch daily:21.04 --name ubuntu-daily

Find a list of instances

You can find the list of running/stopped instances in your machine

multipass list
Name State IPv4 Image
ubuntu-lts Running 10.14.80.157 Ubuntu 20.04 LTS

Start/Stop/restart instances

Starting, stopping, and restarting is as easy as running multipass [start/stop/restart] instance-name

# Stop multipass instance
multipass stop ubuntu-lts
# check status
multipass list
Name State IPv4 Image
ubuntu-lts Stopped -- Ubuntu 20.04 LTS
# start instance
multipass start ubuntu-lts
# restart
multipass restart ubuntu-lts

Open a shell on a running instance

You can directly run certain commands without going into the instance shell, or you can run a shell, and perform multiple commands on that shell.

# run certain commands directly from your host machine
multipass exec ubuntu-lts -- lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
# Or open a shell on a running instance
multipass shell ubuntu-lts
...
ubuntu@ubuntu-lts:~$

Now you can run play around in ubuntu-lts VM instance.

NOTE: here ubuntu@ubuntu-lts:~$ is a login shell for your ubuntu-lts instance.

Finally, we will open some ports in this instance, which will be helpful in future posts to deploy the rails application.

NOTE: make sure you are inside ubuntu-lts instance or run multipass shell ubuntu-lts

# Open port 22 to allow FTP protocol.
# There is a `transfer` command in multipass which will allow you to transfer file between the host and instance, you can use that as well, if you don't want to open port 22.
ubuntu@ubuntu-lts:~$ sudo ufw allow 22# Also install net-tools to find out your instance ip address, important, if you want to ssh into this server later.
ubuntu@ubuntu-lts:~$ sudo apt update
ubuntu@ubuntu-lts:~$ sudo apt install net-tools
# Now you can check your IP Address by running
ubuntu@ubuntu-lts:~$ ifconfig
# And find line that print something like
inet 10.14.80.157 netmask 255.255.255.0 broadcast 10.14.80.255

So 10.14.80.157 is my instance IP address

There are a lot more multipass supports, so check the multipass documentation page for more information.

Hope you enjoy it, happy hacking!!

Next, we are going to setup Ruby on Rails in this multipass instance, and we will treat this instance as a production server for us. If you are interested you can follow along here.

--

--