Difficulty: Beginner
Estimated Time: 10 minutes

buildah logo

Buildah - a tool that facilitates building OCI container images

Buildah creates OCI container images without requiring a Docker Daemon.

In this scenario you will learn how to build images based on existing Dockerfiles using Buildah. You will also learn how to build images from bash scripts allowing for different syntax and approaches to image creation.

The scenario also introduces skopeo, a tool for inspecting images and container registries

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Building Container Images with Buildah

Step 1 of 4

Build from Dockerfile

Buildah is a CLI that facilitates building OCI images. A OCI Image is the open specification for the format that images should be to run on top of OCI compatiable Container Runtimes.

buildah

Example Project

Download the example HTTP Server project written in Go.

git clone https://github.com/katacoda/golang-http-server.git && cd golang-http-server

The cloned project has a Dockerfile. This can be used by both Docker or alternatives like Buildah and Img.

cat Dockerfile

To use the Dockerfile with Buildah, there is a command called Build-Using-Dockerfile.

buildah build-using-dockerfile

This has an alias called Bud.

buildah bud

Given the local directory, it will build the Dockerfile with an assigned tag as a parameter.

buildah bud -t http-server:v1 .

The results is an image.

buildah images

The built image can be pushed to a Docker Registry via the CLI.

buildah push http-server:v1 [[HOST_SUBDOMAIN]]-5000-[[KATACODA_HOST]].environments.katacoda.com/http-server

The result is any Docker host can now deploy our image.

docker run -d -p 80:80 [[HOST_SUBDOMAIN]]-5000-[[KATACODA_HOST]].environments.katacoda.com/http-server

Test it by issuing a HTTP request.

curl localhost