Skip to main content

Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting our team. We will be in touch shortly.Close

  1. Blog
  2. Article

Nathan Hart
on 15 August 2023

Docker on Mac – a lightweight option with Multipass


For those looking for a streamlined, lightweight command line interface for Docker on Mac, look no further. Multipass is a flexible tool that makes it easy to create and run Ubuntu VMs on any platform, and it comes with built-in tools that make running applications like Docker feel native on platforms such as macOS.

What is Multipass?

Multipass is a command line tool that makes managing virtual machines a breeze. From giving you an Ubuntu shell in as little as less than 20 seconds, to creating local miniclouds for test and dev work, it has your Linux needs covered.

Why Run Docker in Multipass?

Multipass is designed to be lightweight, flexible, and efficient. It can run in the background unnoticed, available whenever you might need it.

Multipass has deep host integration, which is a game changer for an application like Docker. You can mount local files with a single command, giving you access to dockerfiles and source code kept in macOS. What’s more, you can alias Linux commands to the host machine, and make them context sensitive in that space. This becomes particularly useful for docker-compose.

Let’s say you have a docker-compose.yml file sitting on your host machine and you need a quick way to test it out. With Multipass, you can run `docker-compose up` directly from your host machine’s terminal, without ever needing to launch an application or shell into a virtual machine.

Multipass runs Docker inside a VM in the same way that other tools such as Docker Desktop do. Multipass, however, gives you control over that VM and any others you might need. Let’s say you need multiple instances of Docker with different configurations applied to each – you can do that with Multipass. Or perhaps you need a few different flavors of Kubernetes and associated applications to run in other VMs on the same local or external network – you can do that with Multipass too.

Docker on Mac with Multipass

If you haven’t yet, install Multipass either via the installer or with brew.

Getting Docker running on Mac with Multipass takes just one command:

`multipass launch docker`

This creates a virtual machine with the latest Ubuntu LTS with Docker preinstalled. It also mounts a workspace, a shared file space between the host and the virtual machine so you can easily transfer data or source code between the two. Of course, if you have an existing folder you want to share, you can mount that after the fact, or modify the above command to something like this:

`multipass launch docker --mount=/path/to/my/folder`

These commands also create aliases for several docker commands: `docker` and `docker-compose`. To use them, you can either prefix them with `multipass`, or you can add the aliases to your path by following the instructions in the output of the above commands (typically something like `XXXX`).

Now, to create a container or run a docker-compose file, just run the command as if you had docker installed natively.

For example:

`docker build -t my-mac-container .` or `docker-compose up`

You should now be up and running with Docker.

Further reading

To learn more about how this works in Multipass, read up on Blueprints or create your own. Leave us a note in Discourse if you have a cool project you want to share or if you’ve got feedback.

Related posts


Benjamin Ryzman
24 September 2024

Data centre networking: What is OVN?

Networking Article

Providing an overview of Open Virtual Network (OVN), its architecture and the main drivers behind it in the data centre networking space. ...


Canonical
6 June 2024

BT Group and Canonical deliver 5G to UK stadiums

Canonical announcements Article

Canonical teamed up with BT to improve connectivity in football stadiums. Find out how we brought 5G coverage to Watford stadium. ...


Canonical
12 September 2023

Faster AI application development with Canonical and NVIDIA AI Enterprise

Ubuntu Article

Ubuntu KVM support comes to NVIDIA AI Enterprise Canonical continues to expand its collaboration with NVIDIA by providing Ubuntu KVM Hypervisor support with NVIDIA AI Enterprise 4.0 — which is generally available starting today. Organisations using GPU virtualisation on Ubuntu can look forward to a seamless migration to the new NVIDIA AI ...