December 3, 2021
install podman on Ubuntu 20.04

How To Install Podman on Ubuntu 20.04 LTS

On this article we will learn how to install and use Podman version 3.3.1 on Ubuntu 20.04 LTS operating system.

Introduction

At first glance Podman and Docker are almost the same, especially in the use of command line interface (CLI). However, architecturally they have a different approach in carrying out their functions. Podman (POD Manager) is a daemonless, open source, Linux native tool designed to make it easy to find, run, build, share and deploy applications using Open Containers Initiative (OCI) Containers and Container Images. Podman directly interacts using runC where Docker depends on daemon for all its functionality. On this article we will learn how to install Podman on Ubuntu 20.04 LTS operating system.

Containers under the control of Podman can either be run by root or by a non-privileged user. Podman manages the entire container ecosystem which includes pods, containers, container images, and container volumes using the libpod library.

Podman Installation On Ubuntu 20.04

The Podman installation process consists of several stages which will be explained below, but previously there are prerequisites that must be completed so that the installation runs smoothly.

Prerequisite

  1. Ubuntu server 20.04 with sufficient disk space
  2. root or non root user with sudo privileged
  3. Good internet connection for downloading requested package

Installation Steps

To install Podman on Ubuntu 20.04 LTS, will be following the steps below :

  1. Source Ubuntu release and add the Podman repository
  2. Update the repository
  3. Install Podman On Ubuntu 20.04
  4. Verify the Podman Installation

Source Ubuntu release and Create APT Source File

The first step is to source release version, by tytping command line below :

. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -

The complete text from the console is as shown below :

mpik@worker1:~$ . /etc/os-release
mpik@worker1:~$ echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
[sudo] password for mpik: 
deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /
mpik@worker1:~$ curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1093  100  1093    0     0    219      0  0:00:04  0:00:04 --:--:--   245
OK
Add Podman APT Source
Add Podman APT Source

Update and Upgrade Package Repository

By updating our Ubuntu system, it will refresh the local list of available packages software to the newer stable version. To update Ubuntu 20.04 LTS repositories, we will use the command line:

sudo apt-get update
sudo apt-get -y upgrade
mpik@worker1:~$ sudo apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease                                                           
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                            
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]    
Get:4 https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04  InRelease [1,642 B]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [297 kB]                     
Get:7 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]                    
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,301 kB]                     
Get:9 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [949 kB]                                 
Get:10 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [178 kB]                                  
Get:11 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [29.0 kB]           
mpik@worker1:~$ sudo apt-get -y upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  chromium-bsu-data fonts-uralic libalut0 libfprint-2-tod1 libglc0 libglewmx1.13 libopenal-data libopenal1
  libsdl2-2.0-0 libsdl2-image-2.0-0 libsndio7.0
Use 'sudo apt autoremove' to remove them.
The following packages have been kept back:
  fwupd fwupd-signed gnome-shell-extension-desktop-icons libegl-mesa0 libfwupd2 libfwupdplugin1 libgbm1 libgl1-mesa-dri
  libglapi-mesa libglx-mesa0 libxatracker2 mesa-vulkan-drivers ubuntu-advantage-tools ubuntu-desktop
  ubuntu-desktop-minimal ubuntu-drivers-common
The following packages will be upgraded:
  adwaita-icon-theme alsa-ucm-conf alsa-utils apparmor apport apport-gtk apt apt-utils base-files bash bluez bluez-cups
  bluez-obexd bolt bsdutils busybox-initramfs busybox-static cheese cheese-common command-not-found deja-dup
  desktop-file-utils dirmngr enchant-2 eog evince evince-common evolution-data-server evolution-data-server-common
  fdisk fonts-noto-color-emoji fonts-noto-mono fonts-opensymbol fprintd friendly-recovery gamemode gdb gdbserver gdm3

Install Podman on Ubuntu 20.04

Finally we will install Podman by using the following command line :

sudo apt-get -y install podman
mpik@worker1:~$ sudo apt-get -y install podman
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  chromium-bsu-data fonts-uralic libalut0 libglc0 libglewmx1.13 libopenal-data libopenal1 libsdl2-2.0-0 libsdl2-image-2.0-0
  libsndio7.0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  catatonit conmon containernetworking-plugins containers-common criu crun fuse-overlayfs fuse3 libfuse3-3 libnet1 libprotobuf-c1
  podman-machine-cni podman-plugins slirp4netns uidmap
The following packages will be REMOVED:
  fuse
The following NEW packages will be installed:
  catatonit conmon containernetworking-plugins containers-common criu crun fuse-overlayfs fuse3 libfuse3-3 libnet1 libprotobuf-c1
  podman podman-machine-cni podman-plugins slirp4netns uidmap
0 upgraded, 16 newly installed, 1 to remove and 352 not upgraded.
Need to get 28.9 MB of archives.
After this operation, 146 MB of additional disk space will be used.

Verify the Podman Installation

After completing Podman installation, then we will verifty it by run the following command to check Podman version.

sudo podman --version
Podman version 3.3.1
Podman version 3.3.1

To query more information about installed Podman configuration and version we will use the following command:

podman info
mpik@worker1:~$ podman info
host:
  arch: amd64
  buildahVersion: 1.22.3
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.0.30, commit: '
  cpus: 2
  distribution:
    distribution: ubuntu
    version: "20.04"
  eventLogger: journald
  hostname: worker1.otodiginet.com
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.11.0-38-generic
  linkmode: dynamic
  memFree: 4635234304
  memTotal: 8312537088
  ociRuntime:
    name: crun
    package: 'crun: /usr/bin/crun'
    path: /usr/bin/crun
    version: |-
      crun version UNKNOWN
      commit: ea1fe3938eefa14eb707f1d22adff4db670645d6
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.1.8
      commit: unknown
      libslirp: 4.3.1-git
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.4.3
  swapFree: 968105984
  swapTotal: 968105984
  uptime: 24m 36.88s
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /home/mpik/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/mpik/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 0
  runRoot: /run/user/1000/containers
  volumePath: /home/mpik/.local/share/containers/storage/volumes
version:
  APIVersion: 3.3.1
  Built: 0
  BuiltTime: Wed Dec 31 16:00:00 1969
  GitCommit: ""
  GoVersion: go1.16.6
  OsArch: linux/amd64
  Version: 3.3.1

How to Use Podman On Ubuntu 20.04

Working with OCI Registries

Podman uses /etc/containers/registries.conf file for registering the container list. When we pull an image using the Podman command, it will look for a list of registries from the its file. We can edit and add different registries in the configuration on this file. Here is the content of /etc/containers/registries.conf file.

mpik@worker1:~$ sudo nano /etc/containers/registries.conf
# intended content. We recommend only adding registries which are completely
# trusted (i.e., registries which don't allow unknown or anonymous users to
# create accounts with arbitrary names). This will prevent an image from being
# spoofed, squatted or otherwise made insecure.  If it is necessary to use one
# of these registries, it should be added at the end of the list.
#
# # An array of host[:port] registries to try when pulling an unqualified image, in order.
unqualified-search-registries = ["docker.io", "quay.io"]
#
# [[registry]]
# # The "prefix" field is used to choose the relevant [[registry]] TOML table;
# # (only) the TOML table with the longest match for the input image name
# # (taking into account namespace/repo/tag/digest separators) is used.
# # 
# # The prefix can also be of the form: *.example.com for wildcard subdomain
# # matching.
# #
# # If the prefix field is missing, it defaults to be the same as the "location" field.
# prefix = "example.com/foo"
#
# # If true, unencrypted HTTP as well as TLS connections with untrusted
# # certificates are allowed.
# insecure = false
#
# # If true, pulling images with matching names is forbidden.
# blocked = false
#
# # The physical location of the "prefix"-rooted namespace.
# #
# # By default, this is equal to "prefix" (in which case "prefix" can be omitted
# # and the [[registry]] TOML table can only specify "location").
# #
# # Example: Given
# #   prefix = "example.com/foo"
# #   location = "internal-registry-for-example.net/bar"
# # requests for the image example.com/foo/myimage:latest will actually work with the
# # internal-registry-for-example.net/bar/myimage:latest image.
/etc/containers/registries.conf file
/etc/containers/registries.conf file

Using Podman On Ubuntu 20.04

On this section, we will learn how to use Podman on Ubuntu, by searching and pulling images and then run a container with the Podman command. On this use case, we will try to use deploy MariaDB container on Podman.

Search Images On Podman

To search for MariaDB, we will run the following command line :

podman search mariadb
mpik@worker1:~$ podman search mariadb
INDEX       NAME                                                          DESCRIPTION                                      STARS       OFFICIAL    AUTOMATED
docker.io   docker.io/library/mariadb                                     MariaDB Server is a high performing open sou...  4414        [OK]        
docker.io   docker.io/linuxserver/mariadb                                 A Mariadb container, brought to you by Linux...  257                     
docker.io   docker.io/webhippie/mariadb                                   Docker image for mariadb                         23                      [OK]
docker.io   docker.io/centos/mariadb-101-centos7                          MariaDB 10.1 SQL database server                 12                      
docker.io   docker.io/wodby/mariadb                                       Alpine-based MariaDB container image with or...  6                       [OK]
docker.io   docker.io/mariadb/server                                      MariaDB Server is a modern database for mode...  39                      [OK]
docker.io   docker.io/ansibleplaybookbundle/mariadb-apb                   An APB which deploys RHSCL MariaDB               0                       [OK]
docker.io   docker.io/centos/mariadb-102-centos7                          MariaDB 10.2 SQL database server                 6                       
docker.io   docker.io/jc21/mariadb-aria                                   Extension of the mariadb image that forces a...  16                      
docker.io   docker.io/kitpages/mariadb-galera                             MariaDB with Galera                              2                       [OK]
docker.io   docker.io/mariadb/maxscale                                    MariaDB MaxScale - The world's most advanced...  16                      [OK]
docker.io   docker.io/colinmollenhour/mariadb-galera-swarm                MariaDb w/ Galera Cluster, DNS-based service...  34                      [OK]
docker.io   docker.io/rightctrl/mariadb                                   Mariadb with Galera support                      2                       [OK]
docker.io   docker.io/centos/mariadb-103-centos7                          MariaDB 10.3 SQL database server                 1                       
docker.io   docker.io/lsioarmhf/mariadb                                   ARMHF based Linuxserver.io image of mariadb      17                      
docker.io   docker.io/jelastic/mariadb                                    An image of the MariaDB SQL database server ...  0                       
docker.io   docker.io/clearlinux/mariadb                                  MariaDB relational database management syste...  3                       [OK]
docker.io   docker.io/demyx/mariadb                                       Non-root Docker image running Alpine Linux a...  0                       
docker.io   docker.io/panubo/mariadb-galera                               MariaDB Galera Cluster                           22                      [OK]
docker.io   docker.io/arm64v8/mariadb                                     MariaDB Server is a high performing open sou...  19                      
docker.io   docker.io/bianjp/mariadb-alpine                               Lightweight MariaDB docker image with Alpine...  15                      [OK]
docker.io   docker.io/toughiq/mariadb-cluster                             Dockerized Automated MariaDB Galera Cluster ...  41                      [OK]
docker.io   docker.io/tiredofit/mariadb                                   Docker MariaDB server w/ S6 Overlay, Zabbix ...  2                       [OK]
docker.io   docker.io/jonbaldie/mariadb                                   Fast, simple, and lightweight MariaDB Docker...  2                       [OK]
docker.io   docker.io/ccitest/mariadb                                     CircleCI test images for MariaDB                 0                       [OK]
quay.io     quay.io/bitnami/mariadb                                       Official build of [Bitnami MariaDB](https://...  0                       
quay.io     quay.io/centos7/mariadb-103-centos7                           MariaDB is a multi-user, multi-threaded SQL ...  0                       
quay.io     quay.io/openstack.kolla/centos-source-mariadb-clustercheck                                                     0                       
quay.io     quay.io/openstack.kolla/centos-source-mariadb-server                                                           0                       
quay.io     quay.io/openstack.kolla/ubuntu-source-mariadb-clustercheck                                                     0                       
quay.io     quay.io/openstack.kolla/ubuntu-source-mariadb-server                                                           0                       
quay.io     quay.io/bitnami/mariadb-galera                                                                                 0                      

Download Image

To download MariaDB image, we will use the command line :

podman pull mariadb
mpik@worker1:~$ podman pull mariadb
✔ docker.io/library/mariadb:latest
Trying to pull docker.io/library/mariadb:latest...
Getting image source signatures
Copying blob 5c37daf8b6b5 done  
Copying blob b4cd9409b0f6 done  
Copying blob 7b1a6ab2e44d done  
Copying blob dbcda06785eb done  
Copying blob 034655750c88 done  
Copying blob f0b757a2a0f0 done  
Copying blob fd6cef4ce489 done  
Copying blob a34cd90f184c done  
Copying blob 3cb89a1550ea done  
Copying blob df9f153bd930 done  
Copying config 12e05d5da3 done  
Writing manifest to image destination
Storing signatures
12e05d5da3c5223e9877e8eb90d68560ff66cedcb955131061d60d093a908f0c

Then we will list and image that is already puleed on our system, by typing command line :

podman images
mpik@worker1:~$ podman images
REPOSITORY                 TAG         IMAGE ID      CREATED      SIZE
docker.io/library/mariadb  latest      12e05d5da3c5  12 days ago  416 MB
Pull and list inage on Podman
Pull and list inage on Podman

Running Container On Podman

On this section, we will try to run MariaDB container based on images that is already pulled. We will type the command line :

odman  run -dit mariadb
mpik@worker1:~$ podman  run -dit mariadb
ac89696478313dd7e2db21acb32db52d13958469ee95f85ab99cbb0fe87cb94d
mpik@worker1:~$ podman ps -a
CONTAINER ID  IMAGE                             COMMAND     CREATED         STATUS                     PORTS       NAMES
ac8969647831  docker.io/library/mariadb:latest  mysqld      51 seconds ago  Exited (1) 51 seconds ago              hungry_robinson
mpik@worker1:~$ 
Running MariaDB Container on Podman
Running MariaDB Container on Podman

Conclusion

So far, we have shown you how to install Podman on Ubuntu 20.04 operating system and create an example how to use it. We pull MariaDB image, and run it on the Podman. I hope this tutorial we be helfful for anyone who need it.

Share this article via :

Leave a Reply

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