This page is no longer maintained. Please refer to How to create an instance.
This document demonstrates various ways to create an instance with Multipass. While every method is a one-liner involving the command launch
, each showcases a different option that you an use to get exactly the instance that you want.
Contents:
- Create an instance
- Create an instance with a specific image
- Create an instance with a custom name
- Create an instance with custom CPU number, disk, and RAM
- Create an instance with primary status
- Create an instance with multiple network interfaces
- Create an instance with a custom DNS
Create an instance
To create an instance with Multipass, execute:
$ multipass launch
…
Launched: keen-yak
This has launched a new instance, which has been randomly named keen-yak
. In particular, when we run multipass info
, we find out that it is an Ubuntu LTS release, namely 18.04, with 1GB RAM, 1 CPU, 5GB of disk:
$ multipass info keen-yak
Name: keen-yak
State: RUNNING
IPv4: 10.140.94.253
Release: Ubuntu 18.04.1 LTS
Image hash: d53116c67a41 (Ubuntu 18.04 LTS)
Load: 0.00 0.12 0.18
Disk usage: 1.1G out of 4.7G
Memory usage: 71.6M out of 985.4M
Create an instance with a specific image
See also:
find
,launch <image>
,info
To find out what images are available, run:
$ multipass find
snapcraft:core18 18.04 20201111 Snapcraft builder for Core 18
snapcraft:core20 20.04 20210921 Snapcraft builder for Core 20
snapcraft:core22 22.04 20220426 Snapcraft builder for Core 22
snapcraft:devel 20220525 Snapcraft builder for the devel series
core core16 20200818 Ubuntu Core 16
core18 20211124 Ubuntu Core 18
18.04 bionic 20220523 Ubuntu 18.04 LTS
20.04 focal,lts 20220505 Ubuntu 20.04 LTS
21.10 impish 20220309 Ubuntu 21.10
22.04 jammy 20220506 Ubuntu 22.04 LTS
daily:22.10 devel,kinetic 20220522 Ubuntu 22.10
appliance:adguard-home 20200812 Ubuntu AdGuard Home Appliance
appliance:mosquitto 20200812 Ubuntu Mosquitto Appliance
appliance:nextcloud 20200812 Ubuntu Nextcloud Appliance
appliance:openhab 20200812 Ubuntu openHAB Home Appliance
appliance:plexmediaserver 20200812 Ubuntu Plex Media Server Appliance
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
docker latest A Docker environment with Portainer and related tools
minikube latest minikube is local Kubernetes
To launch an instance with a specific image, pass the image name or alias to multipass launch
:
$ multipass launch kinetic
Launched: tenacious-mink
multipass info
confirms that we’ve launched an instance of the selected image.
$ multipass info tenacious-mink
Name: tenacious-mink
State: Running
IPv4: 10.49.93.29
Release: Ubuntu Kinetic Kudu (development branch)
Image hash: 5cb61a7d834d (Ubuntu 22.10)
Load: 0.10 0.06 0.02
Disk usage: 1.4G out of 4.7G
Memory usage: 161.8M out of 971.2M
Create an instance with a custom name
See also:
launch ... --name
To launch an instance with a specific name, add the --name
option to the command line:
multipass launch kinetic --name helpful-duck
Launched: helpful-duck
Create an instance with custom CPU number, disk, and RAM
A custom number of CPUs, disk and RAM size is specified using the following arguments:
$ multipass launch --cpu 4 --disk 20G --memory 8G
Launched: giving-catfish
Create an instance with primary status
See also:
launch ... --name primary
An instance can obtain the primary status at creation time if its name is primary
:
$ multipass launch kinetic --name primary
Launched: primary
See the documentation for primary instance for more information.
Create an instance with multiple network interfaces
See also:
launch ... --network
[since version 1.6.0]
Multipass can launch
instances with additional network interfaces, via the --network
option. That is complemented by the networks
command, to find available host networks to bridge with.
This is supported only for images with cloud-init support for Version 2 network config, which in turn requires netplan to be installed. So, from 17.10 and core 16 onward, except for snapcraft:core16
. And then only in the following scenarios:
- on Linux, with LXD
- on Windows, with both Hyper-V and VirtualBox
- on macOS, with the VirtualBox driver
The --network
option can be given multiple times, each one requesting an additional network interface (beyond the default one, which is always present). Each use takes an argument specifying the properties of the desired interface:
name
— the only required value, it identifies the host network to connect the instance’s device to (seenetworks
for possible values)mode
— eitherauto
(the default) ormanual
; withauto
, the instance will attempt automatic network configurationmac
— a custom MAC address to use for the device
These properties can be specified in the format <key>=<value>,…
. but a simpler form with only <name>
is available for the most common use-case. Here is an example:
$ multipass launch --network en0 --network name=bridge0,mode=manual
Launched: upbeat-whipsnake
$ multipass exec upbeat-whipsnake -- ip -br address show scope global
enp0s3 UP 10.0.2.15/24
enp0s8 UP 192.168.1.146/24
enp0s9 DOWN
$ ping -c1 192.168.1.146 # elsewhere in the same network
PING 192.168.1.146 (192.168.1.146): 56 data bytes
64 bytes from 192.168.1.146: icmp_seq=0 ttl=64 time=0.378 ms
[...]
In the example above, we got the following interfaces inside the instance:
enp0s3
— the default interface, that the instance can use to reach the outside world and which Multipass uses to communicate with the instance;enp0s8
— the interface that is connected toen0
on the host and which is automatically configured;enp0s9
— the interface that is connected tobridge0
on the host, ready for manual configuration.
Routing
Extra interfaces are configured with a higher metric (200) than the default one (100). So, by default the instance will only route through them if they’re a better match for the destination IP:
$ multipass exec upbeat-whipsnake -- ip route
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 100
default via 192.168.1.1 dev enp0s8 proto dhcp src 192.168.1.146 metric 200
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15
10.0.2.2 dev enp0s3 proto dhcp scope link src 10.0.2.15 metric 100
192.168.1.0/24 dev enp0s8 proto kernel scope link src 192.168.1.146
192.168.1.1 dev enp0s8 proto dhcp scope link src 192.168.1.146 metric 200
$ multipass exec upbeat-whipsnake -- ip route get 91.189.88.181
91.189.88.181 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 1000
cache
$ multipass exec upbeat-whipsnake -- ip route get 192.168.1.13
192.168.1.13 dev enp0s8 src 192.168.1.146 uid 1000
cache
Create an instance with a custom DNS
In some scenarios the default of using the system-provided DNS will not be sufficient. When that’s the case, you can use the --cloud-init
option to the launch
command, or modify the networking configuration after the instance started.
The --cloud-init
approach
See also:
launch ... --cloud-init
To use a custom DNS in your instances, you can use this cloud-init snippet:
#cloud-config
bootcmd:
- printf "[Resolve]\nDNS=8.8.8.8" > /etc/systemd/resolved.conf
- [systemctl, restart, systemd-resolved]
Replace 8.8.8.8
with whatever your preferred DNS server is. You can then launch the instance using the following:
$ multipass launch --cloud-init systemd-resolved.yaml
The netplan.io approach
After the instance booted, you can modify the /etc/netplan/50-cloud-init.yaml
file, adding the nameservers
entry:
network:
ethernets:
ens3:
dhcp4: true
match:
macaddress: 52:54:00:fe:52:ee
set-name: ens3
nameservers:
search: [mydomain]
addresses: [8.8.8.8]
You can then test it:
$ sudo netplan try
Do you want to keep these settings?
Press ENTER before the timeout to accept the new configuration
Changes will revert in 120 seconds
...