Programming

Easy to Install Podman on Ubuntu 20.04

In this tutorial, we shall show you how it is easy to install Podman on Ubuntu 20.04.

Podman (POD Manager) is a daemonless tool for managing Open Container Initiative (OCI), Docker containers schema 1, Docker containers schema 2, pods (groups of containers), images and volumes.

Podman differs from Docker in two respects that are worth calling attention to:

  • Podman containers run unprivileged (rootless) by default.
  • There is no daemon (service) running.

Install Podman on Ubuntu 20

Prerequisites

Step 1 - Keep the server up to date:

# apt update -y

# apt upgrade -y

Step 2 - Install Podman

Follow these steps to install Podman:

# . /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 -

# sudo apt-get update

# sudo apt-get -y upgrade

# sudo apt-get -y install podman

Step 3 - Verify the installation

# podman info

You should see the Podman configuration and version information of the various components.

Working with OCI Registries

Podman supports multiple container registries. When you specify a container name that does not contain a registry, e.g. store/elastic/metricbeat:7.9.0 rather than docker.io/store/elastic/metricbeat:7.9.0, Podman will consult the registry configuration file (/etc/containers/registries.conf) to obtain a list of registries to pull the container image from.

Add docker.io and registry.access.redhat.com (you can add some other registries too).

Edit /etc/containers/registries.conf:

# vi /etc/containers/registries.conf

Paste the follow contents:

# This is a system-wide configuration file used to
# keep track of registries for various container backends.
# It adheres to TOML format and does not support recursive
# lists of registries.

# The default location for this configuration file is
# /etc/containers/registries.conf.

# The only valid categories are: 'registries.search', 'registries.insecure',
# and 'registries.block'.

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

# If you need to access insecure registries, add the registry’s fully-qualified name.
# An insecure registry is one that does not have a valid SSL certificate or only does HTTP.
[registries.insecure]
registries = []

# If you need to block pull access from a registry, uncomment the section below
# and add the registries fully-qualified name.
#
# Docker only
[registries.block]
registries = []

Save and exit the file.

Working with Podman Images

Search the registries you have configured Podman to use.

# podman search ubuntu-20.04

Show the images that have been downloaded by podman.

# podman images

Next, you can download an image as rootless user.

# podman run hello-world

Note that previously we downloaded the hello-world image as root user, which meant it is stored (by default) a different location, unaccessible to the non-root users. To avoid downloading the image again:

# podman save hello-world | podman load

To see the list of downloaded images:

# podman images

REPOSITORY TAG IMAGE ID CREATED SIZE

docker.io/library/hello-world latest bf756fb1ae65 10 months ago 20.3 kB

To see the running containers:

# podman ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

0c755bba8ded docker.io/library/hello-world:latest /hello 50 seconds ago Exited (0) 49 seconds ago funny_shtern

You can stop then start the most recently used container:

# podman stop --latest
# podman start --latest

To remove the container:

# podman rm --latest

In this tutorial, we have seen how it is easy to install Podman on Ubuntu 20.04.

Related Articles