Debian

How To Install Podman on Debian 12

Podman

In the Linux operating system, the applications can be installed and managed by containerizing them and to manage all the containerizing applications Podman is used. Podman can be used either by the command line interface or its GUI application. It is similar to that of the Docker container engine, but the only difference is that it is a deamon-less architecture. Containers actually are the complete package of an application which not only has the application itself but all the required dependencies needed for the proper function of the respective application.

Outline:

How To Install Podman on Debian 12

Podman due to its new and innovative architecture makes it a favorable choice for developers especially when it comes to Linux operating systems like Debian. Moreover, from the developer’s perspective, it is quite difficult to manage applications due to complex infrastructure and this is where containers come into play. So Podman is the open-source tool that manages all the containers in a Debian system, here are some ways to install it:

Method 1: Through alvistack Repository

Repositories in Linux systems are the locations from where the applications can be installed if a more advanced version is required or if the default repository has the respective application missing. Here are some steps for installing Podman on Debian 12:

Step 1: Add alvistack Repository

The repository related to the advanced packaging tool is usually added to the file which contains all the sources list so to save the address for the repository execute:

echo 'deb http://download.opensuse.org/repositories/home:/alvistack/Debian_12/ /' | sudo tee /etc/apt/sources.list.d/home:alvistack.list

Step 2: Download the Repository Key

Usually installing any application on any Linux system such as Debian through repositories requires an authentication key so in the case of Podman execute:

curl -fsSL https://download.opensuse.org/repositories/home:alvistack/Debian_12/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null

Once you have added the key and the repository update the packages list for the advanced packaging tool so that Podman can be added.

Step 3: Install Podman on Debian 12

Once the repository is successfully added to the advanced packaging tool install Podman on Debian by executing:

sudo apt install podman -y

Now to verify the installation of Podman on Debian check its version:

podman --version

Method 2: Through Flatpak

Just like the advanced packaging tool flatpak is also a package manager that is used to install applications on Debian. Whereas the flathub is the repository that provides the applications to flatpak. Usually, by default, flatpak is not installed on Debian 12 so you have to install it first and for that execute:

sudo apt install flatpak

If you want to get the GUI version of Podman then use this method as flathub provides the desktop version of Podman and for that execute:

flatpak install flathub io.podman_desktop.PodmanDesktop

Now if you encounter the error of no remote refs for flathunb then it means that the repository for flathub is not added in the system so for that execute:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

After that run the installation command again and there will be no error this time:

Now again run the installation command for Podman and to launch the desktop version of Podman execute:

flatpak run io.podman_desktop.PodmanDesktop

Method 3: Through Default Repository

One of the easiest ways to install any application on any of the Linux distributions is by using its default package managing tool as it contains packages for almost all the applications so in the case of Podman execute:

sudo apt install podman podman-compose -y

Now to verify the installation of Podman on Debian check its version

podman --version

Configuring Podman on Debian 12

To make Podman function properly it is necessary to have it configured properly as in the command below I am searching for the images related to docker, but Podman is giving an error of rootless mode. The rootless mode exempts the administrator privileges for editing any application. This approach comes with several advantages in scenarios where attackers won’t be able to gain root access and every user can run, manage, or edit any application on the same system.

podman search docker

Moreover, Podman as mentioned above is demon-less and by default, it uses the rootless mode for interacting with containers. Now to provoke the unprivileged user with network namespaces and user mode networking install the slirp4netns and since for the non-root users, the kernel overlay module is not accessible which results in the unavailability of overlay driver for storage and for that installation of fuse-overlayfs is required:

sudo apt install slirp4netns fuse-overlayfs -y

Now give the number for the subordinate users and the ID for the groups that are associated with the account on which you are going to use Podman. Here I have given a random range for my account linuxways:

sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 linuxways

Since the rootless mode allows running the Podman container on Debian without any administrator rights to run Podman in rootless mode uidmap is a dependency that needs to be installed. This dependency primarily uses the newuidmap and newgidamp executables to map the IDs for the users and groups on the host. As a result of this, the Podman containers can run without requiring admin rights:

sudo apt install uidmap -y

Now try searching for any container, and you will see Podman running in rootless mode.

Using Podman in Debian 12

Podman like Docker can be used for running, building, and managing the containers as it uses the open container initiative which makes it suitable to be used on an industrial level. So here are commands for various tasks that will help you get started with Podman:

1: Searching For Images Using Podman on Debian

The images are a sort of read-only file for the application which is not executable and needs to be built to make it executable. So, search for any image in the Podman execute:

podman search docker

2: Downloading an Image Using Podman in Debian 12

Downloading an image can serve multiple purposes as it can be shared with other users, used on a different architecture or to update the current application. Podman stores the downloaded image in the local storage as it can be reused again, the image can be downloaded by using the pull command with Podman, and for building a container it is not necessary to download its image:

podman pull docker

3: Building an Image with Podman on Debian

For building an image or a container it is required to create a container file or a docker file which contains the code which is basically the instructions for building an image. So for illustration, I have created a docker file that contains the code for building an image of the latest version of Fedora:

sudo nano Dockerfile

Here in the code I have used a dummy email, and using the FROM keyword, I have updated Fedora to the latest version. Next, I updated the packages for Fedora and installed the HTTP server using the run command. Further, the image size is also reduced by cleaning the cache and then the server is directed to port 80 using the EXPOSE command:

# Base on the most recently released Fedora

FROM fedora:latest

MAINTAINER ipbabble email buildahboy@redhat.com # not a real email

# Install updates and httpd

RUN echo "Updating all fedora packages"; dnf -y update; dnf -y clean all

RUN echo "Installing httpd"; dnf -y install httpd && dnf -y clean all

# Expose the default httpd port 80

EXPOSE 80

# Run the httpd

CMD ["/usr/sbin/httpd", "-DFOREGROUND"]


Once you have created and edited the file with the necessary instructions, then use the build command in the same directory in which you have created the docker file:

podman build -t fedora-http-server .


Here the t flag allows the user to name the image and the dot at the end tells that the instruction file is a docker file placed in the same directory.

4: Listing Local Images Using Podman on Debian

The images that are stored in the local storage of Podman can be listed to view their details which include their ID, name size, and creation time. These details can be further used in building an image or managing the build image, to list the images use the images command with Podman:

podman images

5: Running Container Images Using Podman on Debian

To run any image using Podman on Debian use the run command and it will create and start a container from that image, moreover, if the image is not present in the local storage it will automatically pull the image. Here for illustration, I have run the docker image along with its version command:

podman run docker docker -v

Likewise, I have run the image that I have built previously named fedora-http-server. Here in the command below the p flag publishes the ports of the container image to the host and the rm flag is used to remove the cache of the container image once it is terminated:

podman run -p 8080:80 --rm fedora-http-server

Now to verify if the container image is running send the HTTP request to the same port, and if it is running then it will show the HTML code at the output:

curl localhost:8080

To know more about running images using Podman consult its command help by executing:

podman run --help

6: Listing Containers Using Podman in Debian

Containers as mentioned above are the image instances that are used as a starting point and then in the run time, the containers use the parameters provided at their time of creation and execution. Since some containers keep on running in the background it is important to keep track of them and for that listing the running containers can be done by executing:

podman ps

Now to list all of the containers on your Debian system using the Podman use the a flag with ps command:

podman ps -a

To know more about the listing containers using Podman consult its command help by executing:

podman ps --help

7: Managing the Containers Using Podman on Debian

Manning the containers usually includes either stopping, removing, or starting a container image so to stop a container image that is running in the background get its container ID and use the stop command to terminate it:

podman stop f644b0bebb49

Moreover, to remove a container image just get its name by listing the containers and use the rm command like this:

podman rm <container_name>

To create an image from a container just get its container ID and use the commit command with it, this can be helpful if you want to create a container image on another user that is associated with the same Debian system:

podman commit --author "<account-name>" b7159e657427

Here, the author flag allows you to specify the name of the user account in which the image will be created. To know more about the listing containers using Podman consult its command help by executing:

podman commit --help

Removing Podman from Debian 12

To remove the Podman if installed using the repository, use the purge command with the apt package manager:

sudo apt purge podman -y

Since the repositories are saved in the sources.list.d directory, and they are not empty, purge command won’t be able to do it. So, you have to manually delete them by navigating to that respective directory and then using the rm command:

sudo rm alvistack.list

sudo rm home:alvistack.list


To remove the desktop version of Podman just execute:

flatpak remove io.podman_desktop.PodmanDesktop

To remove Podman if installed through the default package manager, then use just execute:

sudo apt remove --autoremove podman podman-compose -y

Conclusion

Podman is a container engine that comes with both the GUI version which is named as Podman desktop and the command line version. The desktop version can be installed from Flatpak and the CLI can be installed either using the alvistack repository or by using the advanced packaging tool. Opensuse gives the deb package as well but on Debian, they are uninstallable due to a broken packages error.

 

Similar Posts