Due to Podman's evolution, this article is now outdated. Please see How to replace Docker with Podman on a Mac, revisited for updated information about using Podman instead of Docker on macOS.
Several months ago, I came back to my desk after lunch and to my chagrin, my macOS was making a long constant blowing sound—the fan was on high speed. Now, mind you, I have a fairly new and beefy Mac. 2.4 GHz, 8-core, 64GB running Big Sur, 11.2.1. So what in the world could be triggering my fan to such a high level? I discovered that the culprit was Docker. And the only way to rid myself of the noise was a Docker restart.
At that moment, I added a task to my To-Do list: Replace Docker with Podman. However, early attempts and initial research proved difficult simply because I wanted it to be just as easy to start Podman on my Mac as is the Docker client. I use Alfred (Spotlight replacement) and launch most things with a quick cmd+space. So, if I couldn’t do the same with Podman, I was going to have to take a hard pass on the replacement. And, unfortunately, there isn’t a one-click, easy Podman macOS install, so I had to stitch a couple of few items together to get that quick launch. To help you have a better experience, I've documented the process here.
[ Readers also liked: From Docker Compose to Kubernetes with Podman ]
A couple of months ago, I was able to get Podman running on my Mac via
podman-machine, but I ran out of time and motivation to convert it into something easy to launch. Fast forward a couple of months,
podman-machine is now deprecated in lieu of Vagrant. (NOTE: I’m talking about the old podman machine project being deprecated. There is a new Podman Machine that is NOT deprecated.) I found a couple of good articles, like Brent and Ashley’s post on
podman remote, which provided most of my answer and helped me figure out how to deal with some fun podman.sock errors. However, I couldn’t find my holy grail. I mean, I’m a lazy dude. My frustration level is measured by the amount of typing or clicks it takes me to do something. And if it’s more than a couple of clicks, I’ll need to go eat more pizza to calm me down. So, here it is in three main parts: The pre-requisites, creating a script, and then creating the macOS app.
1. You’ll need the latest version of VirtualBox
2. Install Vagrant
$ brew install podman
Create the script
4. Create a directory to store the Vagrantfile, such as
/Users/[username]/tools/podman (you’ll need to modify scripts below to use this directory)
Vagrant.configure("2") do |config| config.vm.box = "fedora/32-cloud-base" config.vm.provider "virtualbox" do |vb| vb.memory = "1024" end config.vm.provision "shell", inline: <<-SHELL yum install -y podman groupadd -f -r podman #systemctl edit podman.socket mkdir -p /etc/systemd/system/podman.socket.d cat >/etc/systemd/system/podman.socket.d/override.conf <<EOF [Socket] SocketMode=0660 SocketUser=root SocketGroup=podman EOF systemctl daemon-reload echo "d /run/podman 0770 root podman" > /etc/tmpfiles.d/podman.conf sudo systemd-tmpfiles --create systemctl enable podman.socket systemctl start podman.socket usermod -aG podman $SUDO_USER SHELL end
6. Add the following lines to your
~/.zshrc file to create global environment variables for the Podman host and SSH key. This step allows you to make a successful connection in any terminal window. Note the second variable contains a directory that needs to be changed to reflect your setup.
export CONTAINER_HOST=ssh://firstname.lastname@example.org:2222/run/podman/podman.sock export CONTAINER_SSHKEY=/Users/[username]/tools/podman/.vagrant/machines/default/virtualbox/private_key
7. Create the following bash shell script. Note the change required to reflect your setup. I called my script pman.
#!/bin/bash export VAGRANT_CWD=/Users/[username]/tools/podman ACTION=$1 case $ACTION in "down") echo "Shutting down podman" vagrant halt ;; "up") echo "STARTING podman" vagrant up ;; esac
At this point, you can open a terminal and type
$ pman up to start Podman. But, I told you I was lazy, right? That’s way too many clicks and keypresses for my taste, so I made this a macOS app.
Make it a macOS app
1. Open up Automator on your Mac, and choose Application as your document.
2. Drag and drop the Run Shell Script item into the workflow, and type the following script:
export PATH=/usr/local/bin:$PATH ~/Dev/bin/pman up
Note: The example path
~/Dev/bin/pman will need to be updated to where you saved and named the bash script above.
3. Save the Application. It should save directly into the Mac Applications folder. I called my Podman application Seals because of the Podman logo.
4. As an added bonus, I found the Podman logo and created a 128x128 PNG image with GIMP to use as the application icon:
- Open the 128x128 png in preview and click Edit > Copy
- Right-click the new Application, and click Get Info.
- Select the icon on the top left, and paste the contents of the clipboard.
[ Get this free ebook: Managing your Kubernetes clusters for dummies. ]
There you have it. Now you can use Spotlight or Alfred to run Podman. It’s just a cmd+space and a couple of letters away.