Friday, November 22, 2024
Google search engine
HomeGuest BlogsHow To Install Podman on Debian 12 (Bookworm)

How To Install Podman on Debian 12 (Bookworm)

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

As technology advances over the years, the application and infrastructure become so complex. Developers and system admins find it hard to manage the applications in these environments as it is resource intensive and therefore, expensive. To curb this problem, the concept of containerization was developed. Here, the applications are bundled with all the required dependencies in a lightweight executable known as a container. The technology was quickly adopted and brought several tools such as Docker, Podman, Kubernetes etc, into play.

Podman is an open-source tool used to develop, manage and run containers on Linux systems. It was developed by Redhat engineers, who worked closely with the Open source community. Podman manages the whole container ecosystem using the libpod library. Podman uses a daemon-less architecture. This means that it eliminates the daemon and allows regular users to spin containers without interacting with a daemon owned by Root. This architecture makes it a more accessible and secure tool for container management. It also accompanies tools like Skopeo and Buildah that enables developers to make customizations to the container environments.

Podman offers the following benefits:

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

  • It allows users to manage container images and the full lifecycle of containers such as running, checkpointing, networking and removal of containers.
  • Run isolated resources for rootless containers and pods.
  • It supports OCI and Docker images and the Docker-compatible CLI
  • Improves security with reduced idle resource consumption by creating daemon-less containers
  • Offers advanced functionality via the REST API
  • Automatic update of containers
  • implements checkpoint/restore functionality for Linux containers using CRIU(checkpoint/restore in userspace). This freezes a container then saves the contents ad state disks allowing the container to be restarted faster.

Join me in this guide as we learn how to install Podman on Debian 12 (Bookworm).

1. Update your System

Before we proceed, it is very important to update your system to the latest available version. This can be done using the command:

sudo apt -y update && sudo apt -y upgrade 

Check if a system reboot is required after the upgrade:

[ -f /var/run/reboot-required ] && sudo reboot -f

2. Install Podman on Debian 12 (Bookworm)

There are several ways to install Podman on Debian 12 (Bookworm). In this guide, we will follow any of the two methods below.

  1. Using Default Repositories
  2. Using alvistack APT repository

Method 1: Using Default Debian 12 (Bookworm) Repositories

Podman has been included in the default Debian 12 (Bookworm) repositories and can be installed with the command:

sudo apt install podman podman-compose

Once complete, verify the version:

$ podman version
Client:       Podman Engine
Version:      4.3.1
API Version:  4.3.1
Go Version:   go1.19.8
Built:        Wed Dec 31 19:00:00 1969
OS/Arch:      linux/amd64

Method 2: Using alvistack APT repository

You can also use the alvistack APT repository to install Podman on Debian 12 (Bookworm). First install required dependencies:

sudo apt install curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates -y

First, download and import the GPG key for the repository:

source  /etc/os-release
wget http://downloadcontent.opensuse.org/repositories/home:/alvistack/Debian_$VERSION_ID/Release.key -O alvistack_key
cat alvistack_key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/alvistack.gpg  >/dev/null

Once installed, add the repository to the system:

echo "deb http://downloadcontent.opensuse.org/repositories/home:/alvistack/Debian_$VERSION_ID/ /" | sudo tee  /etc/apt/sources.list.d/alvistack.list

Now update the APT package index:

sudo apt update

Install Podman and its dependencies with the command:

sudo apt install podman python3-podman-compose 

Check the installed version:

$ podman version
Client:       Podman Engine
Version:      4.5.1
API Version:  4.5.1
Go Version:   go1.20.5
Built:        Wed Dec 31 19:00:00 1969
OS/Arch:      linux/amd64

3. Using Podman on Debian 12 (Bookworm)

Once installed, Podman can be used to pull and build container images as well as manage the containers. Below are some of the basic activities you can do with Podman.

a. Pull Container Images

With Podman, you can pull images from the registries or build them locally. To pull an image, use the syntax below:

podman pull <registry/image:tag>

For example, if you need to pull an image from Docker Hub, say Nginx, the command will be:

$ podman pull docker.io/library/nginx:latest
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob 4b98867cde79 done  
Copying blob 5b5fe70539cd done  
Copying blob 441a1b465367 done  
Copying blob 3b9543f2b500 done  
Copying blob ca89ed5461a9 done  
Copying blob b0e1283145af done  
Copying blob 4a85ce26214d done  
Copying config eb4a571591 done  
Writing manifest to image destination
Storing signatures
eb4a57159180767450cb8426e6367f11b999653d8f185b5e3b78a9ca30c2c31d

Check if the image has been pulled to your local registry:

$ podman images
REPOSITORY               TAG         IMAGE ID      CREATED     SIZE
docker.io/library/nginx  latest      eb4a57159180  6 days ago  191 MB

You can remove the image from the local registry using the syntax:

podman rmi <registry/image:tag>

For example:

podman rmi docker.io/library/ubuntu:latest

b. Build Container Images

Aside from pulling the container images, you can also build your own images using Podman then use it locally or upload it to a registry.

First, create the Dockerfile:

vim Dockerfile

in the file, provide the required variables for your image. For example:

FROM ubuntu:20.04
RUN apt-get update -y
ENV DEBIAN_FRONTEND=noninteractive 
RUN apt install -y gnupg apt-transport-https apt-utils wget
RUN echo "deb https://notesalexp.org/tesseract-ocr5/focal/ focal main" \
|tee /etc/apt/sources.list.d/notesalexp.list > /dev/null
RUN wget -O - https://notesalexp.org/debian/alexp_key.asc | apt-key add -
RUN apt-get update -y
RUN apt-get install tesseract-ocr -y
RUN apt install imagemagick -y
ENTRYPOINT ["tesseract"]
RUN tesseract -v

Now build the images based on the file above:

podman build . -t tesseract:latest

Once complete, check if the image exists:

$ podman images
REPOSITORY                TAG         IMAGE ID      CREATED         SIZE
localhost/tesseract       latest      423f068be5f5  54 seconds ago  319 MB
docker.io/library/nginx   latest      eb4a57159180  6 days ago      191 MB
docker.io/library/ubuntu  20.04       626a42b93d93  2 weeks ago     75.2 MB

c. Manage Containers with Podman

Now you can run and manage containers as desired with Podman. You can run a container using existing images or directly pulling them from the registry.

For this example, we will run the Tessetact container using the images built above:

$ podman run tesseract:latest -v
tesseract 5.3.1
 leptonica-1.79.0
  libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 2.0.3) : libpng 1.6.37 : libtiff 4.1.0 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.1
 Found AVX2
 Found AVX
 Found FMA
 Found SSE4.1
 Found OpenMP 201511
 Found libarchive 3.4.0 zlib/1.2.11 liblzma/5.2.4 bz2lib/1.0.8 liblz4/1.9.2 libzstd/1.4.4
 Found libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3

It is also possible to run a container with a non-existing image. For example:

podman run docker.io/library/hello-world

Sample Output:

How To Install Podman on Debian 12 Bookworm

That shows the container is running. To check the status of the containers, use:

$ podman ps -a
CONTAINER ID  IMAGE                                 COMMAND     CREATED         STATUS                     PORTS       NAMES
2c5d5f71a5a0  localhost/tesseract:latest            -v          2 minutes ago   Exited (0) 2 minutes ago               laughing_cannon
c614a2078e19  docker.io/library/hello-world:latest  /hello      54 seconds ago  Exited (0) 54 seconds ago              heuristic_stonebraker

To stop a running container, use:

podman stop container_name/container_ID

To delete a stopped container, use the command:

podman rm container_name/container_ID

d. Manage Containers Using Podman Compose

Podman compose can also be used to manage containers. To use this, you need to have a Docker compose file.

vim docker-compose.yml

In the file, add all the configurations for your container. For example:

version: '3'
services:
  web:
    image: docker.io/library/nginx:latest
    ports:
      - "8080:80"
    volumes:
      - ./src:/usr/share/nginx/html
    links:
      - php
  php:
    image: php:8-fpm

Now run the container:

podman-compose up -d

Sample Output:

....
Trying to pull docker.io/library/php:8-fpm...
Getting image source signatures
Copying blob 5b5fe70539cd skipped: already exists  
Copying blob 9f5fbfd5edfc done  
Copying blob affe9439d2a2 done  
Copying blob 1684de57270e done  
Copying blob dc968f4da64f done  
Copying blob 57fbc4474c06 done  
Copying blob b4d9bb9ce845 done  
Copying blob f51eb8abdfc4 done  
Copying blob 1b8e9625dd32 done  
Copying blob 8cd03ac3d71b done  
Copying config 029eb15dd3 done  
Writing manifest to image destination
Storing signatures
e092b2fc515b509bdd8ead4861236c396c078f565f98efaec11738a18a5a19a1
....

Once started, check the container status:

$ podman-compose ps
CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS        PORTS                 NAMES
e092b2fc515b  docker.io/library/php:8-fpm     php-fpm               2 minutes ago  Up 2 minutes                        debian_php_1
a56d77d3fe0f  docker.io/library/nginx:latest  nginx -g daemon o...  2 minutes ago  Up 2 minutes  0.0.0.0:8080->80/tcp  debian_web_1

Verdict

That marks the end of this guide on how to install Podman on Debian 12 (Bookworm). Now you are in a position to run and manage containers on Debian 12 (Bookworm) using Podman.

Interested in more?

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments