---
title: "Learning Virtual Machine with Multipass"
description: "Exploring something new is safer to do in an **isolated** environment first. For example, in recent weeks I've been exploring whether Podman can replace Docker in my daily workflow."
publishedAt: 2024-05-25
locale: en
urlSlug: belajar-virtual-machine-multipass
isDraft: false
defaultLocale: en
---
[TOC]

## Why do we need Virtual Machines?

Exploring something new is safer to do in an **isolated** environment first. For example, in recent weeks I've been exploring whether [Podman](https://www.threads.net/@wayanjimmy/post/C6EIIuhBYJa) can replace Docker in my daily workflow.

It would be very **risky** if I directly replace Docker with Podman. Instead, I can experiment first through a VM (Virtual Machine), perform testing with several conditions I need, such as:

- Is it compatible with other applications that depend on Docker? in this case [Tilt.dev](https://tilt.dev)
- Is it compatible with docker-compose?
- How do I run Kubernetes in Docker with Podman?

If I can answer the questions above, then my **confidence** increases to be able to replace Docker with Podman, and in the process I don't need to tinker with my Host machine configuration, because the **stability** of the Host Machine is very important for the smoothness of daily work.

Instead, what I tinker with is the VM because if it fails, I just destroy and create a new VM again, do several **iterations**, until I can answer all the questions above.

## Why Multipass?

As an Ubuntu user, [Multipass](https://braindump.fly.dev/notes/20210228151250-multipass/) already covers what I need:

- Create VMs based on Ubuntu
- Can install several ubuntu versions 24.04, 20.04, etc.
- Start without configuration

Compared to Vagrant, I feel Multipass is an improvement!

## How to create a VM

For installation, you can check directly from the [documentation](https://multipass.run/install). To create a VM use the command below.

```bash
multipass launch devbox
```

`devbox` is the name of the VM that you can change, you can also configure many CPU, Memory and Storage allocated for this VM.

```bash
multipass launch -c 2 -d 30G -m 2G --name devbox 24.04
```

The command above means create a VM with 2 CPU, 30 Giga Storage, 2 Giga Memory, with the name devbox and Ubuntu version 24.04

## SSH into the VM

To start tinkering into the VM, we need to ssh first

```bash
multipass shell devbox
```

To start, try running htop

```bash
htop
```

![Run htop](/static/multipass-ubuntu-htop-small.png)

from here you will get information that this VM's CPU is limited to 2 cores, according to the specifications we made, right?

once in the VM we can start installing the application we want to tinker with.

```bash
sudo apt update
sudo apt upgrade
```

![Run htop](/static/multipass-ubuntu-update-small.png)

Let's try installing podman and run the hello world container.

```bash
sudo apt install -y podman podman-docker
```

![Run Podman Hello World](/static/multipass-hello-podman-small.png)

## Delete VM

If you feel you've had enough playing with the VM, you can delete it, and `purge` to free up the storage previously claimed by the VM.

```bash
multipass delete devbox
multipass purge
```

## Conclusion

- VM is one of the tools that can be included in daily equipment as an Application Developer.
- VM provides isolation and allows Developers to replicate an environment, to be as similar as possible to the conditions when running in a Production environment.
- Multipass provides convenience for Developers who are already familiar with Ubuntu and need help with VM tools
