Introduction
For most developers and DevOps professionals, Docker is a platform synonymous with app containerization. However, other projects aim to diversify the offer in the container management market, and Podman is one open-source project that has recently become popular.
This article will show you how to install Podman on macOS using Homebrew.
Prerequisites
- A system running macOS Catalina or higher.
- Access to the terminal.
- A user with admin-level privileges.
Installing Podman on macOS
Podman does not run natively on macOS because it manages only Linux containers. On macOS, Podman interacts with the containers that run in a Linux VM. The easiest way to set up the necessary packages for Podman is to use Homebrew.
STEP 1: Install Homebrew
Homebrew is a command line package manager for macOS.
To install Homebrew on macOS, you will need to install XCode Command Line tools and then download the installation script by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
For a step-by-step Homebrew installation tutorial, read How to Install Homebrew on Mac.
STEP 2: Install Podman Using Homebrew
1. Before installing Podman, update the Homebrew formulae:
brew update
The output shows if there are formulae to be upgraded.
If necessary, perform the upgrade with brew upgrade
.
2. Next, install Podman by running the following command:
brew install podman
Homebrew downloads the necessary dependencies and installs Podman.
STEP 3: Start Podman
1. When the installation finishes, prepare the Podman virtual machine by typing:
podman machine init
The system downloads the virtual machine and sets it up.
2. Enter the following command to start Podman:
podman machine start
The output confirms the system started the Podman machine successfully.
Testing Podman on macOS
1. Test the Podman installation by creating an Nginx container. The example below clones Alpine Nginx from GitHub:
git clone http://github.com/baude/alpine_nginx && cd alpine_nginx
2. Use the podman build
command to create an Nginx image on the system:
podman build -t alpine_nginx .
3. Wait for the process to finish, then create an Nginx container with podman run
:
podman run -dt -p 9999:80 alpine_nginx
Note: The podman run
has the same syntax as docker run.
4. Check running containers by typing:
podman ps -a
The output lists the Nginx container:
5. Use the curl command to test the connection with the container:
curl http://localhost:9999
The command returns a response from Nginx:
Note: Bare Metal Cloud general purpose instances offer compute, memory, and network resources well suited for running containerized microservices.
Using Podman on macOS
Podman on macOS is run using a set of commands that mirror Docker commands. The following are some useful commands to get started with Podman:
Command | Description | Example |
---|---|---|
podman search [image-name] |
Search repositories for an image. | podman search ubuntu |
podman pull [image-name] |
Pull an image from a repository. | podman pull docker.io/library/ubuntu |
podman images |
List locally available images. | podman images |
podman run [image-name] |
Create and run a container using an image. | podman run -dt -p 8080:80 docker.io/library/ubuntu |
podman stop [container-id] |
Stop a running container. | podman stop ca0ecf758897 |
podman rm [container-id] |
Remove a container. | podman rm ca0ecf758897 |
podman rmi [image-name] |
Remove an image. | podman rmi docker.io/library/ubuntu |
podman info |
Receive information about the Podman installation. | podman info |
If you are new to Podman, check out our Podman tutorial article for beginners to get you started.
Conclusion
This tutorial explained how to install Podman on macOS using the Homebrew package manager. Furthermore, it showed a test example of deploying a container with Podman, along with some commonly used commands.
If you are interested in containers, read about the Benefits of Container Orchestration.