For developers and administrators in the current IT-transformed world, container management is a daily activity for creating, maintaining and upgrading an application. The most popular container management tool, as most of us know, is Docker. This article, however, explores Buildah, with some basic examples.
Application deployment is a day-to-day task for a developer, administrator or DevOps admin. Many of us use the open source tool Docker to manage images and containers. In June 2015, the Open Container Initiative (OCI) was launched by Docker, CoreOS and other leaders in the container industry with the aim of using an open standard to run and manage containers.
In the early 90s one had to install Acrobat Reader to open a PDF file. But now, after PDF has become an open standard, we can open such files in any browser.
Like Open PDF standard, there are different open source container runtime management tools, which include:
Buildah helps with creating, building and updating container images. It supports Docker formatted images as well as OCI compliant images.
Buildah builds container images without the need to have a full container runtime or daemon installed. This feature is particularly helpful when setting up a continuous integration and continuous delivery pipeline for building containers. It makes the container’s file system directly available to the build host. This means that the build tooling is available on the host and not needed in the container image, keeping the build faster and the image smaller and safer. There are Buildah packages available for CentOS, Fedora, and Debian.
Since Fedora 26, Buildah can be installed using dnf.
$ sudo dnf install buildah -y
The current version of Buildah is 0.16, which can be displayed by using the following command:
$ buildah --version
The first step needed to build a container image is to get a base image. This is done by the from statement in a Docker file. Buildah handles this in a similar way.
$ sudo buildah from fedora
The above command pulls the Fedora based image and stores it on the host. It is possible to inspect the images available on the host, by running the following code:
$ sudo buildah images IMAGE ID IMAGE NAME CREATED AT SIZE 9110ae7f579f docker.io/library/fedora:latest Mar 7, 2018 20:51 234.7 MB
After pulling the base image, a running container instance of this image is available. This is a ‘working container’.
The following command displays the running containers:
$ sudo buildah containers CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME 6112db586ab9 * 9110ae7f579f docker.io/library/fedora:latest fedora-working-container $ sudo buildah run httpd
The above command will run the httpd image as a container.
This is how we can manage containers without any daemon or service running in the background. Buildah will work as a tool for managing the containers and their runtime.