A tool that facilitates building OCI container images.

This project is maintained by the containers organization.

Subscribe to the blog feed.

buildah logo

Buildah Blocks - OCI Shell Game

By Tom Sweeney GitHub Twitter

I’ve always been fascinated by the three shells and a pea game that street hustlers have used for years to make a bit of coin. I love watching a talented person running the game, but I know better than to bet on it! However, playing the game with Buildah leads to everyone being a winner.

I had a bit of time to play, so I tried out a variant of the shell game with Open Containers Initiative (OCI) containers. I made a quick example showing how you can create an OCI image with Buildah, saved the image to a repository on Docker Hub and then used both Docker and Buildah to run that image from Docker Hub. Nothing terribly fancy, but the video does illustrate that Buildah is OCI-compliant and the images it creates can be used by other OCI-compliant technologies.

The demo was recorded on a Fedora 27 virtual machine that was installed and then updated on December 23, 2017. I decided to “leverage” William Henry’s Buildah Tutorial #1 a bit to create a Dockerfile that runs his runecho.sh file. Prior to the video, I did the following on the virtual machine:

# dnf install -y docker buildah
# dnf update -y
# systemctl start docker

I also created a Dockerfile with these contents:

FROM alpine
ADD runecho.sh /usr/bin
CMD ["/bin/sh", "/usr/bin/runecho.sh"]

In the same directory I created runecho.sh with these contents:

for i in `seq 0 9`;
    echo "This is a new container from ipbabble [" $i "]"

I then modified the privileges on runecho.sh with:

# chmod +x runecho.sh

The demo shows an image built by Buildah being placed on Docker Hub and then run by both Docker and Buildah from there. I’ve included the commands used in the video at the bottom of this blog. I will note that Red Hat is currently developing Podman. Once that is fully developed, the podman run command will be the suggested way to run your container; the Buildah variant of that command will be positioned for quick testing purposes.

I hope that you enjoyed the video and this article gives you a little more information on the Buildah project. Buildah is an Open Source project and contributors are always welcome. We’d love to see you there!

Buildah == Simplicity

Commands used in the video for your perusal:

docker --version
buildah --version
docker login docker.io
buildah bud -t echo .
buildah push echo docker.io/tomsweeneyredhat/blog:echo
docker run docker.io/tomsweeneyredhat/blog:echo
buildah images
docker images
buildah from docker.io/tomsweeneyredhat/blog:echo --name echo
buildah run echo