How to Install and Use Podman on Ubuntu 18.04

Podman is a daemonless container engine that can be used for developing, managing and running OCI Containers on Linux-based operating system. Podman uses a fork/exec model for running containers and can run without root privileges.

In this tutorial, we will learn how to install Podman on Ubuntu 18.04.

Requirements

  • A server running on Ubuntu 18.04.
  • A root password set up on your server.

Getting Started

Before starting, it is recommended to update your system with the latest version. You can do it with the following command:
# apt-get update -y
# apt-get upgrade -y

Once your system is up-to-date, you can proceed to the next step.

Install Podman

By default, Podman is not available in the Ubuntu 18.04 default repository. So, you will need to add the repository for that.

You can add it with the following command:
# apt-get install software-properties-common -y
# add-apt-repository -y ppa:projectatomic/ppa

Next, install Podman with the following command:
# apt-get install podman -y

Once Podman has been installed, you can check all the information of Podman with the following command:
# podman  info

You should see the following output:

host:
BuildahVersion: 1.8.3
Conmon:
package: 'conmon: /usr/bin/conmon'
path: /usr/bin/conmon
version: 'conmon version 0.3.0, commit: unknown'
Distribution:
distribution: ubuntu
version: "18.04"
MemFree: 338325504
MemTotal: 1033875456
OCIRuntime:
package: 'cri-o-runc: /usr/bin/runc'
path: /usr/bin/runc
version: 'runc version spec: 1.0.1-dev'
SwapFree: 1709174784
SwapTotal: 1709174784
arch: amd64
cpus: 1
hostname: ubuntu1804
kernel: 4.15.0-20-generic
os: linux
rootless: false
uptime: 17m 40.72s
registries:
blocked: null
insecure: null
search: null
store:
ConfigFile: /etc/containers/storage.conf
ContainerStore:
number: 0
GraphDriverName: overlay
GraphOptions: null
GraphRoot: /var/lib/containers/storage
GraphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
ImageStore:
number: 0
RunRoot: /var/run/containers/storage
VolumePath: /var/lib/containers/storage/volumes

Working with Podman

Before starting, you will need to defind docker.io registries in the file:

 /etc/containers/registries.conf

You can do it with the following command:
# echo -e "[registries.search]\nregistries = ['docker.io']" | sudo tee /etc/containers/registries.conf
Next, download and run the hello-word image with the following command:
# podman run hello-world

You should see the following output:

Trying to pull docker.io/library/hello-world...Getting image source signatures
Copying blob 1b930d010525 done
Copying config fce289e99e done
Writing manifest to image destination
Storing signatures
Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
  3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

# docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:

https://hub.docker.com/

For more examples and ideas, visit:

https://docs.docker.com/get-started/

Next, you can see the list of downloaded images with the following command:

# podman images

You should see the following output:

REPOSITORY                      TAG      IMAGE ID       CREATED        SIZE
docker.io/library/hello-world   latest   fce289e99eb9   6 months ago   6.14 kB

You can also see the running container with the following command:

# podman ps -a

You should see the following output:

CONTAINER ID  IMAGE COMMAND  CREATED STATUS PORTS  NAMES
c6c20824a698  docker.io/library/hello-world:latest  /hello   3 minutes ago  Exited (0) 3 minutes ago upbeat_elion

 

You can start and stop the container with the following command:
# podman stop --latest
# podman start --latest

To remove the container, run the following command:

# podman rm --latest

Conclusion

Congratulations! You have successfully installed Podman on Ubuntu 18.04 server. You can now easily create, run and maintain containers using Podman. For more information, please, go to the Podman documentation at https://github.com/containers/libpod/blob/master/docs/tutorials/podman_tutorial.md

To write a comment on this article, fill out the form below. Fields marked with an asterisk (*) are required.