Skip to content

Commit c78e208

Browse files
authored
Merge pull request #81 from giuliazanchi/multipass-55bis
Added markdown version of Multipass tutorials
2 parents 43c1e86 + 758a785 commit c78e208

File tree

3 files changed

+1164
-0
lines changed

3 files changed

+1164
-0
lines changed

multipass/Linux.md

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
nhart | 2023-12-07 11:18:47 UTC | #1
2+
3+
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.
4+
5+
This tutorial will give you an understanding of how Multipass works, and the skills you need to use its main features.
6+
7+
8+
## Contents
9+
- [Install Multipass](#heading--install-multipass)
10+
- [Create and use a basic instance](#heading--create-and-use-a-basic-instance)
11+
- [Create a customised instance](#heading--create-a-customised-instance)
12+
- [Manage instances](#heading--manage-instances)
13+
- [Put your instances to use](#heading--put-your-instances-to-use)
14+
- [Run a simple web server](#heading--run-a-simple-web-server)
15+
- [Launch from a Blueprint to run Docker containers](#heading--launch-from-a-blueprint-to-run-docker-containers)
16+
- [Next steps](#heading--next-steps)
17+
18+
19+
<a href="#heading--install-multipass"><h2 id="heading--install-multipass">Install Multipass</h3></a>
20+
21+
Multipass is available for Linux, macOs, or Windows. To install it on your OS of choice, please follow the instructions given [here](https://multipass.run/docs/how-to-guides). Note: This tutorial demonstrates use on Linux, specifically Ubuntu, but the experience on any OS should be similar.
22+
23+
24+
<a href="#heading--create-and-use-a-basic-instance"><h2 id="heading--create-and-use-a-basic-instance">Create and use a basic instance</h2></a>
25+
26+
<!--
27+
The easiest way to use Multipass is with the primary instance.
28+
Linux,
29+
The primary instance is a Multipass virtual machine that is configured to be useful for generic purposes out of the box.
30+
31+
The primary instance automatically mounts the $HOME directory (files in this directory are shared between the host and the instance), and it comes with Multipass’s default specs: 1GB of RAM, 5GB of disk, and 1 CPU.
32+
-->
33+
34+
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.
35+
36+
![|800x450](https://assets.ubuntu.com/v1/949aa05e-mp-linux-1.png)
37+
38+
Once we’ve launched the application, we should see the Multipass tray icon in the upper right section of the screen:
39+
40+
![|688x52](https://assets.ubuntu.com/v1/5ec546da-mp-linux-2.png)
41+
42+
Let's click on the icon, then on “Open Shell”.
43+
44+
![|286x274](https://assets.ubuntu.com/v1/3ecc5e7d-mp-linux-2a.png)
45+
46+
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 printout below.
47+
48+
```plain
49+
Launched: primary
50+
Mounted '/home/<user>' into 'primary:Home'
51+
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-57-generic x86_64)
52+
53+
* Documentation: https://help.ubuntu.com
54+
* Management: https://landscape.canonical.com
55+
* Support: https://ubuntu.com/advantage
56+
57+
System information as of Thu Jan 26 08:06:22 PST 2023
58+
59+
System load: 0.0 Processes: 95
60+
Usage of /: 30.2% of 4.67GB Users logged in: 0
61+
Memory usage: 21% IPv4 address for ens3: 10.110.66.242
62+
Swap usage: 0%
63+
64+
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
65+
just raised the bar for easy, resilient and secure K8s cluster deployment.
66+
67+
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
68+
69+
0 updates can be applied immediately.
70+
71+
72+
The list of available updates is more than a week old.
73+
To check for new updates run: sudo apt update
74+
75+
ubuntu@primary:~$
76+
```
77+
78+
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:
79+
80+
![|720x405](https://assets.ubuntu.com/v1/fbfc8304-mp-linux-3.png)
81+
82+
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:
83+
84+
```plain
85+
ubuntu@primary:~$ cd ./Home/Multipass_Files/
86+
ubuntu@primary:~/Home/Multipass_Files$ cat README.md
87+
## Shared Folder
88+
89+
This folder could be a great place to keep files that need to be accessed by both your host machine and Ubuntu VM!
90+
91+
ubuntu@primary:~/Home/Multipass_Files$
92+
```
93+
94+
Congratulations, you've got your first instance!
95+
96+
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!
97+
98+
[details = "Optional Exercises"]
99+
Exercise 1:
100+
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).
101+
102+
Exercise 2:
103+
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.
104+
[/details]
105+
106+
<a href="#heading--create-a-customised-instance"><h2 id="heading--create-a-customised-instance">Create a customised instance</h3></a>
107+
108+
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.
109+
110+
```plain
111+
$ multipass find
112+
Image Aliases Version Description
113+
snapcraft:core18 18.04 20201111 Snapcraft builder for Core 18
114+
snapcraft:core20 20.04 20210921 Snapcraft builder for Core 20
115+
snapcraft:core22 22.04 20220426 Snapcraft builder for Core 22
116+
snapcraft:devel 20230126 Snapcraft builder for the devel series
117+
core core16 20200818 Ubuntu Core 16
118+
core18 20211124 Ubuntu Core 18
119+
core20 20230119 Ubuntu Core 20
120+
core22 20230119 Ubuntu Core 22
121+
18.04 bionic 20230112 Ubuntu 18.04 LTS
122+
20.04 focal 20230117 Ubuntu 20.04 LTS
123+
22.04 jammy,lts 20230107 Ubuntu 22.04 LTS
124+
22.10 kinetic 20230112 Ubuntu 22.10
125+
daily:23.04 devel,lunar 20230125 Ubuntu 23.04
126+
appliance:adguard-home 20200812 Ubuntu AdGuard Home Appliance
127+
appliance:mosquitto 20200812 Ubuntu Mosquitto Appliance
128+
appliance:nextcloud 20200812 Ubuntu Nextcloud Appliance
129+
appliance:openhab 20200812 Ubuntu openHAB Home Appliance
130+
appliance:plexmediaserver 20200812 Ubuntu Plex Media Server Appliance
131+
anbox-cloud-appliance latest Anbox Cloud Appliance
132+
charm-dev latest A development and testing environment for charmers
133+
docker 0.4 A Docker environment with Portainer and related tools
134+
jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
135+
minikube latest minikube is local Kubernetes
136+
```
137+
138+
Let’s launch an instance running Ubuntu 22.10 (“Kinetic Kudu”) by typing the command `multipass launch kinetic`
139+
140+
Now we have an instance running which has been named randomly by Multipass, in my case it is called coherent-trumpetfish.
141+
142+
```plain
143+
$ multipass launch kinetic
144+
Launched: coherent-trumpetfish
145+
```
146+
147+
We can check some basic info about our new instance by running the following:
148+
149+
`multipass exec coherent-trumpetfish -- lsb_release -a`
150+
151+
This tells multipass to execute the command `lsb_release -a` on the “coherent-trumpetfish” instance.
152+
153+
```plain
154+
$ multipass exec coherent-trumpetfish -- lsb_release -a
155+
No LSB modules are available.
156+
Distributor ID: Ubuntu
157+
Description: Ubuntu 22.10
158+
Release: 22.10
159+
Codename: kinetic
160+
```
161+
162+
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 coherent-trumpetfish instance by running
163+
164+
`multipass delete coherent-trumpetfish`
165+
166+
Let’s now launch the type of instance we’re looking for by running this:
167+
168+
`multipass launch lts --name ltsInstance --memory 2G --disk 10G --cpus 2`
169+
170+
<a href="#heading--manage-instances"><h2 id="heading--manage-instances">Manage instances</h3></a>
171+
172+
Now let’s confirm this new instance has the specs we’re looking for by running `multipass info ltsInstance`
173+
174+
```plain
175+
$ multipass info ltsInstance
176+
Name: ltsInstance
177+
State: Running
178+
IPv4: 10.110.66.139
179+
Release: Ubuntu 22.04.1 LTS
180+
Image hash: 3100a27357a0 (Ubuntu 22.04 LTS)
181+
CPU(s): 2
182+
Load: 1.11 0.36 0.12
183+
Disk usage: 1.4GiB out of 9.5GiB
184+
Memory usage: 170.4MiB out of 1.9GiB
185+
Mounts: --
186+
```
187+
188+
We’ve created and deleted quite a few instances now. Let’s run multipass list to see what instances we currently have.
189+
190+
```plain
191+
$ multipass list
192+
Name State IPv4 Image
193+
primary Running 10.110.66.242 Ubuntu 22.04 LTS
194+
coherent-trumpetfish Deleted -- Not Available
195+
ltsInstance Running 10.110.66.139 Ubuntu 22.04 LTS
196+
```
197+
198+
We have two instances currently running, the primary instance and our LTS machine with customised specs. Our coherent-trumpetfish instance is still listed, but its state is “Deleted”. We can recover this instance by running `multipass recover coherent-trumpetfish`, 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:
199+
200+
```plain
201+
$ multipass list
202+
Name State IPv4 Image
203+
primary Running 10.110.66.242 Ubuntu 22.04 LTS
204+
ltsInstance Running 10.110.66.139 Ubuntu 22.04 LTS
205+
```
206+
207+
We’ve now seen a few ways to create, customise, and delete an instance. Now let’s put those instances to work!
208+
209+
<a href="#heading--put-your-instances-to-use"><h2 id="heading--put-your-instances-to-use">Put your instances to use</h2></a>
210+
211+
<a href="#heading--run-a-simple-web-server"><h3 id="heading--run-a-simple-web-server">Run a simple web server</h3></a>
212+
213+
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.
214+
215+
From the shell, we can now run:
216+
217+
```
218+
sudo apt update
219+
220+
sudo apt install apache2
221+
```
222+
223+
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.
224+
225+
![|720x545](https://assets.ubuntu.com/v1/e106f7f9-mp-linux-4.png)
226+
227+
Just like that, we’ve got a web server running in a Multipass instance!
228+
229+
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.
230+
231+
<a href="#heading--launch-from-a-blueprint-to-run-docker-containers"><h3 id="heading--launch-from-a-blueprint-to-run-docker-containers">Launch from a Blueprint to run Docker containers</h3></a>
232+
233+
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`
234+
235+
Once that’s finished, let’s run `multipass info docker-dev` to note down the IP of the new instance.
236+
237+
```plain
238+
$ multipass launch docker --name docker-dev
239+
Launched: docker-dev
240+
$ multipass info docker-dev
241+
Name: docker-dev
242+
State: Running
243+
IPv4: 10.115.5.235
244+
172.17.0.1
245+
Release: Ubuntu 22.04.1 LTS
246+
Image hash: 3100a27357a0 (Ubuntu 22.04 LTS)
247+
CPU(s): 2
248+
Load: 1.50 2.21 1.36
249+
Disk usage: 2.6GiB out of 38.6GiB
250+
Memory usage: 259.7MiB out of 3.8GiB
251+
Mounts: --
252+
```
253+
254+
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.
255+
256+
![|720x543](https://assets.ubuntu.com/v1/75a164a1-mp-linux-5.png)
257+
258+
From there, let’s select a local docker environment.
259+
260+
![|720x601](https://assets.ubuntu.com/v1/ee3ff308-mp-linux-6.png)
261+
262+
From there, we can click into the newly created “local” docker endpoint, navigate to the app templates page, and select NGINX
263+
264+
![|720x460](https://assets.ubuntu.com/v1/86be3eae-mp-linux-7.png)
265+
266+
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!
267+
268+
![|720x465](https://assets.ubuntu.com/v1/25585a03-mp-linux-8.png)
269+
270+
<a href="#heading--next-steps"><h2 id="heading--next-steps">Next steps</h2></a>
271+
272+
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](https://multipass.run/docs/how-to-guides) for ideas and for help with your project. Our [reference page](https://multipass.run/docs/reference) contains definitions of key concepts, a complete CLI command reference, settings options and more.
273+
274+
Let us know what you’re able to get done with Multipass!
275+
276+
-------------------------
277+
278+
mscho7969 | 2023-08-23 16:15:33 UTC | #2
279+
280+
It seems like Screenshots located in Google Photo are disappear. :sweat_smile:
281+
282+
Same in
283+
- [Multipass Tutorial - Windows | Multipass documentation](https://multipass.run/docs/windows-tutorial)
284+
- [Multipass Tutorial - macOS | Multipass documentation](https://multipass.run/docs/mac-tutorial).
285+
286+
Need to be change alternative images or remove image sections.
287+
288+
-------------------------
289+
290+
townsend | 2023-07-07 12:20:42 UTC | #3
291+
292+
Hi @mscho7969!
293+
294+
Thanks for letting us know about the missing graphics! I'll follow up and try to figure out what happened to them.
295+
296+
-------------------------
297+
298+
sally-makin | 2023-07-07 13:54:25 UTC | #4
299+
300+
Thanks for taking the time to report that, @mscho7969 - we appreciate your help :) We've fixed the links now so hopefully there won't be any more problems!
301+
302+
-------------------------
303+
304+
itecompro | 2023-12-01 22:07:54 UTC | #5
305+
306+
Under the 'Create a customised instance' heading, there is a wrong instance name (close to the end).
307+
308+
Wrong: `deluxe-ghoul`
309+
Right: `coherent-trumpetfish`
310+
311+
> We can delete the deluxe-ghoul instance by running
312+
313+
-------------------------
314+
315+
andreitoterman | 2023-12-07 11:49:58 UTC | #6
316+
317+
Good catch, @itecompro. Thanks!
318+
319+
-------------------------
320+

0 commit comments

Comments
 (0)