--- stage: Verify group: Pipeline Execution info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments --- # Tutorial: Use Buildah in a rootless container with GitLab Runner Operator on OpenShift **(FREE)** This tutorial teaches you how to successfully build images using the `buildah` tool, with GitLab Runner deployed using [GitLab Runner Operator](https://gitlab.com/gitlab-org/gl-openshift/gitlab-runner-operator) on an OpenShift cluster. This guide is an adaptation of [using Buildah to build images in a rootless OpenShift container](https://github.com/containers/buildah/blob/main/docs/tutorials/05-openshift-rootless-build.md) documentation for GitLab Runner Operator. To complete this tutorial, you will: 1. [Configure the Buildah image](#configure-the-buildah-image) 1. [Configure the service account](#configure-the-service-account) 1. [Configure the job](#configure-the-job) ## Prerequisites - A runner already deployed to a `gitlab-runner` namespace. ## Configure the Buildah image We start by preparing a custom image based on the `quay.io/buildah/stable:v1.23.1` image. 1. Create the `Containerfile-buildah` file: ```shell cat > Containerfile-buildah < /etc/subuid \ && echo build:10000:65536 > /etc/subgid # Use chroot since the default runc does not work when running rootless RUN echo "export BUILDAH_ISOLATION=chroot" >> /home/build/.bashrc # Use VFS since fuse does not work RUN mkdir -p /home/build/.config/containers \ && (echo '[storage]';echo 'driver = "vfs"') > /home/build/.config/containers/storage.conf # The buildah container will run as `build` user USER build WORKDIR /home/build EOF ``` 1. Build and push the Buildah image to a container registry. Let's push to the [GitLab container registry](../../user/packages/container_registry/index.md): ```shell docker build -f Containerfile-buildah -t registry.example.com/group/project/buildah:1.23.1 . docker push registry.example.com/group/project/buildah:1.23.1 ``` ## Configure the service account For these steps, you need to run the commands in a terminal connected to the OpenShift cluster. 1. Run this command to create a service account named `buildah-sa`: ```shell oc create -f - <