Docker on Apple M1 breaks on Jupyter Notebooks for AMD64/Intel so switch to Podman

Well with the licensing change that Docker is making everyone seems to be looking for an alternative, but this got real when @alex realized that the Docker Desktop for the Mac does not work with Jupyter Notebooks running on AMD64 that is 64-bit Intel at all after v4.0 and they won’t fix it. It seems to work with other containers, so YMMV running docker with AMD64 images.

The problem is that there are many folks who are not converting their work to ARM64 because they are research projects, so for some things you need to run Intel images. Now Docker for Desktop does ship with its own fork of the QEMU but it is version 5 so a year old and something they did in their proprietary code cause jupyter notebooks for linux/amd64 to generate an error 6 under QEMU.

The solution is that Podman does not have this problem. It first of all uses the latest QEMU 6.2 and there have been a lot of work in the last year to get it to work. So if you have crusty old things like h5py for instance that don’t have AARCH64 equivalents here is what you do. Note there are ton of out of date issues from the last months as folks have fixed almost all of them:

  1. Podman. Podman is a daemon-less docker equivalent made by Red Hat. This means you don’t need a daemon or the docker gui and it doesn’t run as root which is great. Installation is easy on an Apple M1 Macs with brew install podman
  2. Podman initialization. The tricky part is that if you do the normal podman init machine and podman start machine to get a Linux virtual machine running that machine will not have QEMU support so will only work with AARCH64 containers.
  3. Podman QEMU. The solution is that you do a podman machine ssh to get into the machine that then install qemu and everything just kind of works with sudo rpm-ostree install qemu-user-static && systemctl reboot which will install qemu on that machine
  4. Now you can run any container you want like podman run --rm --it --platform linux/amd64 hello-world will actually run the x86 image not the arm64 image neat huh!

And you have now gotten rid of docker completely. Every command that starts with docker works with podman and in fact, you can run alias docker=podman if you want.

There are bunch of things that don’t really work though, so if you want to run Kubernetes then it is a different story. While is supposed to be possible for instance with Kind to run with Podman this doesn’t work on M1s. But you can run Kind directly with Docker desktop (with native

As an aside if you want to do it you can test this by then running

docker run -dt --rm --name nb -p 8888:8888 --platform linux/amd64 jupyter/minimal-notebook
# inside the notebook run this code
import platform

And you should get the notation that shows it is runnnig aarch64 with amd64 simulation!

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect