Content outline

Jul 14, 2024
4 Min read

Getting started with Podman

In this tutorial, we will install Podman on an Ubuntu 24.04 server and run qube-server which is a tiny web server used for testing purposes.

Podman logo in grey background.

Prerequisites

You will need an Ubuntu 24.04 virtual or bare-metal server for this tutorial. If you do not have access to a virtual or bare-metal server, you can quickly run an Ubuntu virtual server on your laptop with Multipass.

Outline

What is Podman

Podman is an open-source tool for building and running containers. Unlike Docker, Podman is daemonless so it is less resource-intensive than Docker.

Podman is production-ready and is an alternative to Docker for running your containerized workloads.

Install Podman

Log in to the Ubuntu server and install Podman with Ubuntu package manager.

$ sudo apt-get update
$ sudo apt-get install podman

The podman package is available on Ubuntu versions later than 20.04. If you are using an older Ubuntu version, you can install Podman by compiling from source.

Run qube-server on Podman

Run qube-server.

$ podman run --name qube_server -p 8080:8080/tcp -dt docker.io/cloudqubes/qube-server:1.0.1

Flags and parameters used in the run command:

  • -p: Publish container port 8080 to port 8080 on the host (Ubuntu server).
  • -d: Run the container in background.
  • -t: Assign a pseudo-TTY to qube-server so we can log in to the container via SSH if required for debugging etc.
  • docker.io/cloudqubes/qube-server:1.0.1: The URL to pull the container.

List running containers:

$ podman ps
CONTAINER ID  IMAGE                                   COMMAND     CREATED        STATUS        PORTS                   NAMES
f4f4ee1e0a4f  docker.io/cloudqubes/qube-server:1.0.1              7 seconds ago  Up 7 seconds  0.0.0.0:8080->8080/tcp  qube_server

Test qube-server with curl

Test qube-server root path:

$ curl http://127.0.0.1:8080
Hello cloud

Test the /count path:

$ curl http://127.0.0.1:8080/count
Count: 1
$ curl http://127.0.0.1:8080/count
Count: 2

The first request to the /count initializes a counter which increments at each subsequent request to the /count path.

Check out what happens to the counter as we pause and unpause the container next.

Pause and unpause container

Pause container:

$ podman pause <container_id>

List all containers including paused:

$ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS      PORTS                   NAMES
f4f4ee1e0a4f  docker.io/cloudqubes/qube-server:1.0.1              43 minutes ago  Paused      0.0.0.0:8080->8080/tcp  qube_server

Unpause container:

$ podman unpause <container_id>

Send new request to the /count path:

$ curl http://127.0.0.1:8080/count
Count: 3

We can see that a paused container retains its memory since the /count returns 3 continuing the counter started before the container is paused.

Print container logs

$ podman logs <container_id>

The container_id is the first field in the output of the podman ps command.

Stop and remove containers

Stop the qube-server container:

$ podman stop <container_id>

List stopped containers:

$ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                     PORTS                   NAMES
f4f4ee1e0a4f  docker.io/cloudqubes/qube-server:1.0.1              51 minutes ago  Exited (2) 41 seconds ago  0.0.0.0:8080->8080/tcp  qube_server

Stopping does not remove the container, so we must explicitly remove:

$ podman rm <container_id>

List the images

List the cached images:

$ podman images
REPOSITORY                        TAG         IMAGE ID      CREATED       SIZE
docker.io/cloudqubes/qube-server  1.0.1       65ecceaf2ddf  10 hours ago  4.59 MB

Podman has cached the qube-server image so it does not have to download image if we are to run qube-server again.

Wrapping up

In this tutorial, we installed Podman and deployed qube-server web server on Podman.

Podman is production ready so you can use it as an alternative to Docker for running containerized applications in production.

Podman commands and functions are quite similar to Docker. So your learning curve for switching from Docker to Podman will be pretty smooth. But there are many differences as well.

We will delve into these differences between Podmand and Docker in an upcoming article.