Linux MintUbuntu Based

How To Install Podman on Linux Mint 21

Install Podman on Linux Mint 21

In this tutorial, we will show you how to install Podman on Linux Mint 21. Podman, a powerful and flexible open-source container engine, has gained significant popularity among developers and system administrators alike. As an alternative to Docker, Podman offers a daemonless architecture, enhanced security features, and compatibility with existing Docker commands.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Podman daemonless container engine on Linux Mint 21.

Prerequisites

  • A server running one of the following operating systems: Linux Mint 21.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • While we’ll guide you through the process, a basic understanding of the command line will be beneficial. If you’re new to the CLI, you might want to acquaint yourself with some fundamental commands.
  • An active internet connection.
  • Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.

Install Podman on Linux Mint 21

Step 1. To begin, open a terminal and update your system to ensure you have the latest packages and security patches installed. Run the following command:

sudo apt update
sudo apt upgrade

Next, install the necessary dependencies by executing the following command:

sudo apt install curl gnupg2 software-properties-common

Step 2. Installing Podman on Linux Mint 21.

To install Podman on Linux Mint 21, you need to add the official Podman repository to your system. This ensures that you have access to the latest version of Podman and can easily update it in the future.

To add the Podman repository, run the following command:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/podman-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_21.04/ /" | sudo tee /etc/apt/sources.list.d/podman.list

Import the Podman GPG key by running the following command:

curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_21.04/Release.key | sudo gpg --dearmor -o /usr/share/keyrings/podman-archive-keyring.gpg

Now that the Podman repository is configured, you can proceed with installing Podman:

sudo apt update
sudo apt install podman

Once the installation is complete, verify that Podman is installed correctly by checking its version:

podman --version

Step 3. Configuring Podman.

After installing Podman, you may want to configure it to suit your specific needs. Here are a few common configuration options:

  • Setting up rootless containers:

Podman allows you to run containers as a non-root user, enhancing security. To set up rootless containers, follow these steps:

sudo useradd -m -U -G sudo podman_user

Switch to the new user account:

sudo su - podman_user

Set up the necessary directories and permissions:

mkdir -p ~/.config/containers
mkdir -p ~/.local/share/containers

Configure Podman to use the rootless mode by default:

echo "export PODMAN_ROOTLESS=1" >> ~/.bashrc
source ~/.bashrc
  • Configuring storage options:

Podman allows you to customize storage options for containers. By default, Podman uses the overlay file system for storage. However, you can switch to other storage drivers like devicemapper or btrfs if needed.

To configure storage options, modify the Podman configuration file:

sudo nano /etc/containers/storage.conf

Uncomment and modify the driver option to specify your desired storage driver.

  • Enabling Podman auto-updates:

To ensure that Podman is always up to date with the latest bug fixes and security patches, you can enable auto-updates. Run the following command to enable auto-updates:

sudo systemctl enable --now podman-auto-update.timer
  • Integrating with systemd for managing containers:

Podman integrates seamlessly with systemd, allowing you to manage containers as systemd services. To generate a systemd unit file for a container, use the podman generate systemd command followed by the container name or ID. For example, to generate a systemd unit file for a container named my-container, run:

podman generate systemd --name my-container > my-container.service

Step 4. Running Your First Container with Podman

Now that you have Podman installed and configured, let’s run your first container. Follow these steps:

  • Pull an image from a container registry:

Podman allows you to pull container images from various container registries, such as Docker Hub, Quay.io, or your own private registry. To pull an image, use the podman pull command followed by the image name and tag. For example, to pull the latest version of the Ubuntu image, run:

podman pull ubuntu:latest
  • Run a simple container:

Once you have pulled an image, you can run a container based on that image using the podman run command. For example, to run a container based on the Ubuntu image and execute a simple command, run:

podman run ubuntu:latest echo "Hello, Podman!"
  • Exposing ports and mounting volumes:

Podman allows you to expose container ports to the host system and mount host directories into the container. To expose a port, use the -p or --publish flag followed by the host port and container port. For example, to run an Nginx container and expose port 80, run:

podman run -p 8080:80 nginx

To mount a host directory into the container, use the -v or --volume flag followed by the host directory and the container mount point. For example, to mount the /path/to/data directory on the host to /data in the container, run:

podman run -v /path/to/data:/data my-container
  • Managing containers with Podman commands:

Podman provides a set of commands to manage containers effectively. Here are a few commonly used commands:

  • podman ps: List running containers
  • podman ps -a: List all containers (running and stopped)
  • podman start <container>: Start a stopped container
  • podman stop <container>: Stop a running container
  • podman rm <container>: Remove a container
  • podman logs <container>: View container logs
  • podman exec -it <container> <command>: Execute a command inside a running container

These commands allow you to manage the lifecycle of your containers effectively.

Congratulations! You have successfully installed Podman. Thanks for using this tutorial to install the latest version of the Podman daemonless container engine on the Linux Mint system. For additional help or useful information, we recommend you check the official Podman website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button