Install and Use Podman on Debian 12 Bookworm: Best Container Manager

Posted on

Install and Use Podman on Debian 12 Bookworm: Best Container Manager

Install and Use Podman on Debian 12 Bookworm: Best Container Manager

This tutorial guides you through the process of installing and using Podman on Debian 12 Bookworm. Podman, a powerful open-source container management tool, is a valuable asset for developers and system administrators working with Linux-based systems. It offers a daemon-less architecture, enhanced security features, and compatibility with Docker images, making it a compelling alternative to Docker. You can install Podman from the APT repository. Podman is an open-source container management tool for Linux-based distros that can be used for:

  • Developing containerized applications
  • Testing software in isolated environments
  • Deploying applications consistently across different platforms
  • Managing containers without requiring root privileges

Follow the steps outlined on the Orcacore website to Install and Use Podman on Debian 12 Bookworm.

Before you begin, ensure you have access to your Debian 12 Bookworm server as a non-root user with sudo privileges. If you haven’t already, you can follow this guide on Initial Server Setup with Debian 12 Bookworm for assistance.

Now, let’s dive into the steps required to Install and Use Podman on Debian 12 Bookworm.

Step 1 – Install Podman with APT on Debian 12

First, update your system’s package list using the following command:

sudo apt update

This command synchronizes your package lists with the repositories, ensuring you have the latest information about available packages.

The Podman packages are readily available in the default Debian 12 repository. Install Podman using the following command:

sudo apt install podman -y

This command downloads and installs Podman and its dependencies. The -y flag automatically confirms the installation, preventing prompts.

After the installation is complete, verify it by checking the Podman version:

podman --version

This command displays the installed Podman version, confirming a successful installation.

**Output**
podman version 4.3.1

Step 2 – How To Start Podman on Debian Linux?

After installing Podman, start and enable the Podman socket service using the following commands:

sudo systemctl start podman.socket
sudo systemctl enable podman.socket

The first command starts the podman.socket service, which listens for container management requests. The second command enables the service to start automatically on boot.

Verify that the Podman service is active and running on your Debian 12 system using:

sudo systemctl status podman.socket

This command displays the status of the podman.socket service, confirming whether it’s active and running.

Start Podman on Debian Linux

To obtain comprehensive information about Podman, use the following command:

podman info

This command provides detailed information about your Podman installation, including storage configuration, registries, and other relevant details.

podman info command

Step 3 – How To Configure Podman Registries on Debian Linux?

In this step, you’ll configure Podman registries. Podman’s ability to search and pull images from various registries is a valuable feature. You can customize the list of container registries by editing the registry configuration file. Open the file using the following command:

sudo vi /etc/containers/registries.conf

This command opens the registries.conf file in the vi text editor. You can use other editors like nano if you prefer.

Add the following content to the file:

unqualified-search-registries = [ 'registry.access.redhat.com', 'registry.redhat.io', 'docker.io']

This configuration tells Podman to search the specified registries when you use the podman search or podman pull commands. The registries are searched in the order they appear in the list.

Save and close the file after making the changes.

Restart the Podman service to apply the changes:

sudo systemctl restart podman.socket

This command restarts the podman.socket service, ensuring that the new registry configuration is loaded.

Step 4 – How To Use Podman on Debian 12 Bookworm?

Now that Podman is installed and configured, you can start using it to manage containers. This section demonstrates how to search for and pull images and create containers using Podman.

Search Images with Podman

Similar to Docker, you can use the podman search command to search for images. For example, to search for the Debian image, use the following command:

podman search debian

This command searches the configured registries for images matching the "debian" keyword and displays the results.

Search Images with Podman

Download or Pull Images with Podman

Once you’ve found the image you need, you can pull it using the podman pull command:

podman pull debian

This command downloads the specified image from the registry to your local system.

Download or Pull Images with Podman

List All Downloaded Images with Podman

To view a list of all the images you have downloaded, use the podman images command:

podman images

This command displays a table containing information about the images, including their repository, tag, image ID, and size.

In my case:

List All Downloaded Images with Podman

Create a Container with Downloaded Images with Podman

Once you have the image, create a container using it. Here, we’ll create a container using the Debian image we downloaded.

Use the following command to create a container:

podman run -dit --name orca debian

Note: --name is a parameter used to assign a friendly name to the container.

  • -d: Runs the container in detached mode (in the background).
  • -i: Keeps STDIN open even if not attached.
  • -t: Allocates a pseudo-TTY.
  • --name orca: Assigns the name "orca" to the container.
  • debian: Specifies the image to use for creating the container.

To access your container’s command line, use the following command:

podman attach orca

This command attaches your terminal to the container’s console.

You’ll notice that your command prompt changes to reflect your container ID:

deb@305535c6f095:/#

To start your container, use the following command:

podman start container-id or name

To stop your container, use this command:

podman stop container-id or name

For further information, consult the Podman Documentation page.

Conclusion

You have successfully learned to Install and Use Podman on Debian 12 Bookworm, configure Podman registries, and use it to search, pull images, and create containers. Install and Use Podman on Debian 12 Bookworm is a skill that will serve you well.

Hope you enjoy it. You may also be interested in these articles:

Alternative Solutions for Container Management on Debian 12

While Podman is an excellent container management tool, other options exist that might be more suitable depending on your specific needs and environment. Here are two alternative solutions:

1. Docker

Docker is the most widely used containerization platform, and it’s fully supported on Debian 12. While Podman is daemon-less, Docker relies on a daemon process (dockerd). Docker offers a rich ecosystem of tools, extensive documentation, and a large community, which can be advantageous for troubleshooting and finding solutions. It also provides features like Docker Compose for managing multi-container applications.

Installation and Usage:

Docker is readily available through the Docker repositories. The process for installing it involves adding the Docker repository to your system and then installing the docker-ce (Docker Community Edition) package.

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo 
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian 
  bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Verify the installation
sudo docker run hello-world

After installation, the docker command is used similarly to podman, although some commands and options might differ. Docker Compose simplifies the management of multi-container applications. You define your application’s services in a docker-compose.yml file and then use docker-compose up to start the entire application.

2. LXC/LXD

LXC (Linux Containers) is another containerization technology that utilizes the Linux kernel’s built-in containerization features. LXD is a container hypervisor built on top of LXC, providing a user-friendly experience with features like image management, networking, and storage. LXC/LXD offers lightweight virtualization and excellent performance, making it suitable for resource-intensive applications. It’s particularly well-suited for system containers that mimic full operating systems.

Installation and Usage:

LXD can be installed from the Debian repositories using apt.

sudo apt update
sudo apt install lxd lxd-client

#Initialize LXD (Follow the prompts)
sudo lxd init

After the installation, you can manage containers using the lxc command. LXD provides a REST API, enabling integration with other tools and systems. You can launch containers from pre-built images or create your own custom images.

# Launch an Ubuntu container
lxc launch ubuntu:22.04 my-container

# Access the container's console
lxc exec my-container -- bash

# Stop the container
lxc stop my-container

These alternative solutions offer different approaches to containerization, each with its own strengths and weaknesses. The choice between Podman, Docker, and LXC/LXD depends on factors like your specific requirements, existing infrastructure, and familiarity with the tools. Install and Use Podman on Debian 12 Bookworm is a great start, but exploring these alternatives can broaden your understanding of containerization.

Leave a Reply

Your email address will not be published. Required fields are marked *