Lightweight container tools: Podman

Lightweight container tools: Podman

29 March 2021

Glenn Janssens

In this series of blogs, we at FlowFactor want to share a few handy lightweight container tools we discovered while working on a recent client project. They’re a pleasure to work with so we thought we’d share some insights about them! In this series, we will go deeper into Podman, Buildah, Skopeo and Dive

Tip:
Many podman, buildah and skopeo commands have a return value. It can be convenient to have the return value of a command to issue the next one. For example “podman start $(podman ps -a)” would start all containers you currently have. This is completely optional.

Podman 

First up is podman, Short for POD MANager. Podman is a CLI utility that can help you create and maintain containers and pods. Libpod, maintained in the same repository, is in essence a container lifecycle management API for podman to use. Together, they offer support for OCI and Docker images.

Moreover, all the Docker commands you’re used to, you can use with podman as well. While they feel like alternatives for one another, I can confirm they are not and that there are many differences. Some things which in my opinion elevate podman: lightweight utility, daemonless, OCI compliance, an advanced REST API and rootless mode for containers. On top of that, podman is backed by Red Hat and now installed by default on RHEL8. Let’s look into a couple of commands.

$ podman pull nginx:latest
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob c5df295936d3 done
Copying blob b3ddf1fa5595 done
Copying blob 232bf38931fc done
Copying blob a29b129f4109 done
Copying blob 852e50cd189d done
Copying config daee903b4e done
Writing manifest to image destination
Storing signatures
daee903b4e436178418e41d8dc223b73632144847e5fe81d061296e667f16ef2

This will give us the latest version of NGINX from Dockerhub. We can use it to create, start and stop a new NGINX container.

$ podman images
REPOSITORY                              TAG                 IMAGE ID      CREATED       SIZE
docker.io/library/nginx                 latest              daee903b4e43  34 hours ago  137 MB

$ podman ps -a
CONTAINER ID  IMAGE                                          COMMAND               CREATED             STATUS                  PORTS                                           NAMES
8b2ab0834606  docker.io/library/nginx:latest                 nginx -g daemon o...  About a minute ago  Created                 0.0.0.0:8080->80/tcp                            quizzical_elgamal

$ podman rm quizzical_elgamal
8b2ab08346061ab4adbc210567dc92302511f9dd0e81175a4b6923bfc1846ed8

$ podman create --name=nginx -p 8080:80 nginx:latest
aa172a0f0c4cffd5b802ff3350048f43fba11547eb5581f7d07bbcde30ac3acf

$ podman start nginx
nginx

$ curl localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
...
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
</body>
</html>

$ podman stop nginx
aa172a0f0c4cffd5b802ff3350048f43fba11547eb5581f7d07bbcde30ac3acf

$ podman inspect nginx
[
    {
        "Id": "aa172a0f0c4cffd5b802ff3350048f43fba11547eb5581f7d07bbcde30ac3acf",
        "Created": "2020-11-19T19:36:04.172357141+01:00",
        "Path": "/docker-entrypoint.sh",
        "Args": [
            "nginx",
            "-g",
            "daemon off;"
        ],
        "State": {
            "OciVersion": "1.0.2-dev",
            "Status": "configured",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "0001-01-01T00:00:00Z",
            "FinishedAt": "0001-01-01T00:00:00Z",
            "Healthcheck": {
                "Status": "",
                "FailingStreak": 0,
                "Log": null
            }
        },
        "Image": "daee903b4e436178418e41d8dc223b73632144847e5fe81d061296e667f16ef2",
        "ImageName": "docker.io/library/nginx:latest",
        ....

$ podman rm nginx
aa172a0f0c4cffd5b802ff3350048f43fba11547eb5581f7d07bbcde30ac3acf

$ podman rmi daee903b4e43
Untagged: docker.io/library/nginx:latest
Deleted: daee903b4e436178418e41d8dc223b73632144847e5fe81d061296e667f16ef2

That’s it for our first entry in our Container Tools blog series. If you want to learn more, check out our next entry on Buildah, a super handy container image building tool, when it becomes available!

Related posts
No Comments

Sorry, the comment form is closed at this time.