Podman is a free, open-source, and Linux native tool used to run, build, share and deploy applications using containers. It allows you to manage containers and images, volumes mounted into those containers. Podman is a daemonless containerization engine so it is rapidly gaining popularity amongst developers as a replacement for Docker.

In this post, we will show you how to install and use Podman on CentOS 8.

Prerequisites

  • A server running CentOS 8.
  • A root password is configured on the server.

Install Podman

First, you will need to install EPEL repo to your system. You can install it using the following command:

dnf install epel-release -y

After installing the EPEL repo, run the following command to install Podman:

dnf install podman -y

Once the Podman is installed, verify the installed version of Podman with the following command:

podman --version

You should see the following output:

podman version 3.0.2-dev

To get detailed information, run the following command:

podman info

You should see the following output:

host:
  arch: amd64
  buildahVersion: 1.19.8
  cgroupManager: systemd
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.26-3.module_el8.4.0+830+8027e1c4.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.26, commit: 9dea73702793340168deaa5a0d21ca5ce1fcb5d7'
  cpus: 2
  distribution:
    distribution: '"centos"'
    version: "8"
  eventLogger: file
  hostname: centos8
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 4.18.0-193.6.3.el8_2.x86_64
  linkmode: dynamic
  memFree: 479723520
  memTotal: 4130037760
  ociRuntime:
    name: runc
    package: runc-1.0.0-73.rc93.module_el8.4.0+830+8027e1c4.x86_64
    path: /usr/bin/runc
    version: |-
      runc version spec: 1.0.2-dev
      go: go1.15.7
      libseccomp: 2.4.1
  os: linux

Find and Download Image with Podman

To find a Debian image, run the following command:

podman search debian

You should see all available Debian images in the following output:

INDEX      NAME                                                        DESCRIPTION                                      STARS   OFFICIAL  AUTOMATED
docker.io  docker.io/library/debian                                    Debian is a Linux distribution that's compos...  3894    [OK]      
docker.io  docker.io/smartentry/debian                                 debian with smartentry                           6                 [OK]
docker.io  docker.io/library/ubuntu                                    Ubuntu is a Debian-based Linux operating sys...  12423   [OK]      
docker.io  docker.io/samueldebruyn/debian-git                          a minimal docker container with debian and g...  22                [OK]
docker.io  docker.io/i386/debian                                       Debian is a Linux distribution that's compos...  14                
docker.io  docker.io/jdub/debian-sources-resource                      Concourse CI resource to check for updated D...  0                 [OK]
docker.io  docker.io/itscaro/debian-ssh                                debian:jessie                                    28                [OK]
docker.io  docker.io/eboraas/debian                                    Debian base images, for all currently-availa...  8                 [OK]
docker.io  docker.io/amd64/debian                                      Debian is a Linux distribution that's compos...  6                 
docker.io  docker.io/arm32v7/debian                                    Debian is a Linux distribution that's compos...  72                
docker.io  docker.io/dockershelf/debian                                Repository for docker images of Debian. Test...  1                 [OK]
docker.io  docker.io/ppc64le/debian                                    Debian is a Linux distribution that's compos...  4                 
docker.io  docker.io/arm64v8/debian                                    Debian is a Linux distribution that's compos...  26                
docker.io  docker.io/spritsail/debian-builder                          A Docker image based on debian:slim ideal fo...  1                 [OK]
docker.io  docker.io/arm32v5/debian                                    Debian is a Linux distribution that's compos...  2                 
docker.io  docker.io/vpgrp/debian                                      Docker images of Debian.                         2                 
docker.io  docker.io/multiarch/debian-debootstrap                      multiarch ports of debian-debootstrap            13                
docker.io  docker.io/1and1internet/debian-9-nginx-php-7.2-wordpress-4  debian-9-nginx-php-7.2-wordpress-4               0                 [OK]
docker.io  docker.io/mdoerges/debian-buster-nginx                      Debian Buster with Nginx                         0                 
docker.io  docker.io/fleshgrinder/debian                               Debian base images for production and multis...  0                 [OK]
docker.io  docker.io/s390x/debian                                      Debian is a Linux distribution that's compos...  2                 
docker.io  docker.io/vicamo/debian                                     Debian docker images for all versions/archit...  3                 
docker.io  docker.io/konstruktoid/debian                               Debian base image                                0                 [OK]
docker.io  docker.io/casept/debian-amd64                               A debian image built from scratch. Mostly fo...  0                 
docker.io  docker.io/vergissberlin/debian-development                  Docker debian image to use for development, ...  6                 [OK]

Next, download the Debian image using the following command:

podman pull debian

You should get the following output:

Resolved "debian" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/debian:latest...
Getting image source signatures
Copying blob 0bc3020d05f1 done  
Copying config 7a4951775d done  
Writing manifest to image destination
Storing signatures
7a4951775d157843b47250a2a5cc7b561d2abe0b29ae6f19737a04635302eacf

Next, verify the downloaded image using the following command:

podman images

You should get the following output:

REPOSITORY                TAG     IMAGE ID      CREATED       SIZE
docker.io/library/debian  latest  7a4951775d15  33 hours ago  119 MB

Run a Container with Podman

You can now launch a container from the Debian image using the following command:

podman run -dit --name debian-container debian

You should get the following output:

5fb79d2ff9748be9474977852db989d4de489546526683e840c501249823a4bf

You can also verify the running container using the following command:

podman ps

You should see the following output:

CONTAINER ID  IMAGE                            COMMAND  CREATED         STATUS             PORTS   NAMES
5fb79d2ff974  docker.io/library/debian:latest  bash     29 seconds ago  Up 28 seconds ago          debian-container

To connect the running container, run the following command:

podman attach debian-container

Once you are connected, you should get the following output:

[email protected]:/#

You can also run any command inside the running container:

[email protected]:/# apt-get update

To exit from the Debian container, run the following command:

[email protected]:/# exit

To check log of the running container, run the following command:

podman logs -f debian-container

To stop the running container, run the following command:

podman stop debian-container

To remove the stopped container, run the following command:

podman rm debian-container

Manage Pods with Podman

In this section, we will show you how to manage pods using Podman.

To create a new pod named webserver, run the following command:

podman pod create --name webserver

You should get the following output:

9cc9b2bdcfe1b774129f2d5b50a4b52c746a0f8917780ae7f2c786fa7767cd19

To list all pods, run the following command:

podman pod list

You should get the following output:

POD ID        NAME       STATUS   CREATED         INFRA ID      # OF CONTAINERS
9cc9b2bdcfe1  webserver  Created  21 seconds ago  3a0c7750fed9  1

To check a running container inside your pod, run the following command:

podman ps -a --pod

You should get the following output:

CONTAINER ID  IMAGE                                         COMMAND  CREATED         STATUS   PORTS   NAMES               POD ID        PODNAME
3a0c7750fed9  registry.access.redhat.com/ubi8/pause:latest           38 seconds ago  Created          9cc9b2bdcfe1-infra  9cc9b2bdcfe1  webserver

To add a new CentOS container to a pod, run the following command:

podman run -dt --pod webserver centos:latest top

You should get the following output:

Resolved "centos" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/centos/centos:latest...
Getting image source signatures
Copying blob 7a0437f04f83 done  
Copying config 300e315adb done  
Writing manifest to image destination
Storing signatures
fcd9a724097759c29330bd57e557eab9778b3d6736695ebf9afedfbd9c0db5e3

Now, verify the added container using the following command:

podman ps -a --pod

You should get the following output:

CONTAINER ID  IMAGE                                         COMMAND  CREATED             STATUS             PORTS   NAMES                 POD ID        PODNAME
3a0c7750fed9  registry.access.redhat.com/ubi8/pause:latest           About a minute ago  Up 16 seconds ago          9cc9b2bdcfe1-infra    9cc9b2bdcfe1  webserver
fcd9a7240977  quay.io/centos/centos:latest                  top      17 seconds ago      Up 16 seconds ago          recursing_goldwasser  9cc9b2bdcfe1  webserver

Conclusion

In the above guide, you learned how to install and use Podman to manage containers on CentOS 8. Podman is very similar to Docker and a great replacement to make your job easier.

Share this page:

Suggested articles

0 Comment(s)

Add comment