Why you should consider Podman for containerization
At Miro, we’re constantly evolving and innovating, and appreciate technologies that allow us to maintain this mindset: To explore, tinker, and iterate is deeply ingrained in Miro’s culture.
This mindset carries over into the tools we might choose to use. For instance, while Docker has been one of the most popular containerization tools for a while, I have recently considered Podman as an alternative because it comes with several benefits I don’t get with Docker. I like Podman because it allows me to experiment with diverse technologies.
What is Podman?
Podman is a lightweight, adaptable, open-source containerization tool that provides a sandbox for testing, refining, and implementing groundbreaking ideas. This not only cultivates a culture of continuous learning, but also helps ensure that I am poised to adapt to the ever-changing demands of the digital landscape.
With Podman, I can run containers without a daemon and without unnecessary processes hogging up our system resources. This provides certain security and usability benefits and makes it perfect for production usage.
Podman focuses on using Open Container Initiative (OCI) containers. It can run the containers without requiring root privileges, meaning they are rootless containers.
Traditionally, containers have been run by the Docker daemon, which often requires root access to manage the container lifecycle. However, running containers as root can introduce security risks and can potentially compromise the host system. By using rootless containers, you can separate your various projects and eliminate compatibility issues.
So, if you’re looking for a lightweight and efficient solution for your project needs, Podman may just be the answer you’ve been looking for. Let’s see how to get Podman running on your machine and use it for project purposes.
Installing Podman
Before installing Podman, you need to check if your system meets the requirements. Podman can run on MacOS, Windows, and on most Linux distributions including Fedora, CentOS, and Ubuntu.
To install Podman, add the Podman repository to your system. You would typically follow the instructions provided by the official Podman documentation or the documentation for your specific OS.
Here is how to add the Podman repository for different operating systems.
Mac OS
Open a terminal.
Podman is provided through Homebrew. Once you have set up brew, you can use the homebrew commands to install Podman:
$ brew install podman
Next, create and start your first Podman machine:
$ podman machine init
$ podman machine start
Verify the podman installation information using:
$ podman info
Windows
On Windows, each Podman machine is backed by a virtualized Windows System for Linux (WSLv2) distribution. Once installed, the Podman command can be run directly from your Windows PowerShell (or CMD) prompt, where it remotely communicates with the Podman service running in the WSL environment. Alternatively, you can access Podman directly from the WSL instance if you prefer a Linux prompt and Linux tooling.
After installing Podman, you need to set up the configuration.
The default configuration should work fine, but you might want to modify it to suit your needs. The configuration file is located at /etc/containers/storage.conf. You can modify it using any text editor.
Linux: Ubuntu
Add the Podman repository using the following commands:
$ sudo apt update
$ sudo apt install -y software-properties-common
$ sudo add-apt-repository -y ppa:projectatomic/ppa
Update your package list again:
$ sudo apt update
Now, install Podman:
$ sudo apt install -y podman
Linux: Fedora
Podman is often available in the default repositories of Fedora. You can install it using the package manager directly:
sudo dnf install -y podman
Linux: CentOS/RHEL
Podman may be available in the EPEL (Extra Packages for Enterprise Linux) repository. You can enable the repository and install Podman using the following commands:
sudo dnf install -y epel-release
sudo dnf install -y podman
For other distributions, I recommend checking the Podman documentation for the recommended way to install Podman and add its repository.
It’s also important to remember that software installation procedures can change over time, which is another reason to consult the latest documentation. Be sure to also consider your system’s specific requirements and security practices when installing software and adding repositories.
How to create and manage the containers
Creating a container is pretty straightforward; all you need is a container image. You can use pre-built images from the Podman registry or use one that you’ve built yourself. You can even find images on Docker Hub and use them with Podman.
To create a container, use `podman run` command followed by the image name.
For example, if you want to create a container with the Ubuntu image, the command would be:
$ podman run -it ubuntu
The `-it` option opens an interactive terminal in the container. Once you run the command, you’ll be inside the container, and you can run any command you want.
Use the `podman stop` command followed by the container ID or name to stop the podman anytime:
$ podman stop CONTAINER_ID_OR_NAME
If you want to start a container again after you’ve stopped it, you can use the `podman start` command followed by the container ID or name:
$ podman start CONTAINER_ID_OR_NAME
Once you’ve created the container, you’ll want to monitor its resource usage. To do that, you can run the `podman stats` command:
$ podman stats CONTAINER_ID_OR_NAME
This command will display the resource usage of the container, including the CPU and memory usage.
With Podman, you can also rename containers, remove stopped containers, and even commit changes to a new image. Managing containers has never been easier!
How to manage images
This is an important part of using Podman for projects. With Podman, you can easily download various images, save them, and use them in your containers. You can download images from a registry like Docker Hub and store different images, or create your own customized images and use them in your containers.
If you want to share your images with the world, you can upload them to a registry. This makes it easier for others to access and use your images. This can be useful when you collaborate with others on a project.
Podman also makes it easy to tag and untag images. This can help you keep track of the different versions of your images and ensure that you are using the correct images in your containers.
Podman makes managing images a breeze. Whether you’re downloading images, uploading them to a registry, or tagging and untagging them, Podman has it covered. So go ahead and play around with images.
How to do networking with Podman
Next, let’s go over some basic networking concepts. Containers are isolated environments with their own network stack and interfaces. This means that they can communicate with other containers and/or the outside world using network ports.
With Podman, networking with containers is a snap. You can create your own custom networks or use the default bridge network. Once you have a network set up, you can easily connect your containers to it using the ` — network` flag.
Now, let’s talk about container port sharing. Sharing ports allows you to access services running inside the container from outside the container. Just use the ` — publish` or `-p` flag followed by the port number you want to share.
Overall, networking with Podman is simple and intuitive.
How to manage storage
Storage is an essential part of containerization. Podman makes creating and managing volumes an easy task. Volumes can be created using this command:
$ podman volume create
These volumes can be used to store data that must be preserved even after the container is destroyed.
When creating a container, directories can be mapped between the host and the containers using the `-v` flag. This allows easy sharing of data between containers and the host machine. Managing these mappings is also very easy with Podman.
Overall, Podman provides a robust storage management solution for containerization. With the ability to create and manage volumes and map directories between the host and containers, users can easily manage their data.
Conclusion
Podman is a safer, faster, and lighter container that does not overload the system, and easily manages images, networks, and storage.
Hope you found this interesting, and if you want to dive deep into it, then Podman documentation will help.
Have you had a different experience with Podman or prefer another containerization tool? Let me know in the comments — I’m interested in what you have to say!
Are you interested in joining Miro? Then check out our open positions. Finally, don’t forget to try Miro or the Miro Developer Platform, where you can build apps on top of Miro.