Podman on macOS (M1 & QEMU 7)

Guillem Riera
3 min readJul 5, 2022
A boat full with containers
Photo by Venti Views on Unsplash

Update: Podman Learning Playbook

I have put together a small Podman Jupyter Notebook that you can check to get an overview of Podman’s features, check it out in GitHub.

Introduction

Podman is an awesome open source container engine that is API compatible with Docker and has Kubernetes’ Pod-like capabilities.

The installation on macOS is unspectacular. A simple command is enough to install it and its dependencies (like QEMU):

brew install podman

TLDR: Are you searching for a fix on a M1 mac?

# After $(podman init)
# Obtain the PODMAN_MACHINE name
# This will get the default one, set this value if you need another
export PODMAN_MACHINE=$(podman machine list -q --format '{{.Name}}')
sed -e 's/cortex-a57/host/g' -e 's/highmem=off/highmem=on/g' -i"" $HOME/.config/containers/podman/machine/qemu/$PODMAN_MACHINE.json

Initialising a VM for Podman

Podman, like Docker Desktop or Rancher Desktop requires a virtual machine (macOS cannot run containers natively) that will actually run the containers.

On macOS the first action after istalling Podman is to init a new (the default) machine, which will be a 2GB RAM, 20GB disk QEMU VM:

podman machine init

Increasing VM Resources

If you need more resources, disk space or enable rootfulness (so that the daemon runs as a privileged service, which might be required for some use cases, like `minikube`), you can init a machine with custom settings like this:

podman machine init --cpus 2 --memory 8192 --rootful

Solving problems on M1 (and QEMU 7)

So far so good.

But a recent issue occurs when using QEMU 7, which prevents starting a VM on macOS running on top of M1 processors.

If you installed podman using homebrew this can eventually happen when you upgrade your homebrew packages.

This is what happens if happend to customize your VM and then boot:

Starting machine "podman-machine-default"
Waiting for VM ...
Error: dial unix /var/folders/kk/vvrx0k6x2b54wnnhc0zt6rv00000gr/T/podman/podman-machine-default_ready.sock: connect: connection refused

Essentially it is a pure configuration problem (or let’s say, a configuration generation problem):

  • The wrong CPU setting is stored for the podman machine (`cortex-a57`, which is a pretty well known ARMv8 model)
  • The memory setting prevents using more than 4GB of RAM for the machine, as `highmem=off` limits addressing to 32 bit space (having more than that is desireable if you intend to run `minikube` on top of it. More of this in upcoming post).

Here is how I managed to get this working on my M1 Pro laptop:

# Obtain the PODMAN_MACHINE name
# This will use the default one, set this value otherwise to the target one in your computer
export PODMAN_MACHINE=$(podman machine list -q --format '{{.Name}}')

Afterwards change the QEMU settings for this machine with

`cpu=host` and `highmem=on`

These settings are place here:

~/.config/containers/podman/machine/qemu/$PODMAN_MACHINE.json

I do so this way (programmatically but in an idempotent way):

sed -e 's/cortex-a57/host/g' -e 's/highmem=off/highmem=on/g' -i""  $HOME/.config/containers/podman/machine/qemu/$PODMAN_MACHINE.json

This command modifies the default podman machine QEMU file inline, searching for those 2 strings and replacing them with the right values.

Afterwards starting a machine works as expected:

podman machine start $PODMAN_MACHINE

Hopefully this issue will be corrected soon.
I hope this help others in the meanwhile.

--

--

Guillem Riera

Principal Technical Consultant, DevOps, CICD Architect