Skip to content

Instantly share code, notes, and snippets.

@bmaupin
Last active October 1, 2019 20:19
Show Gist options
  • Save bmaupin/80c7fd0fc81f234100fb61965e258ae9 to your computer and use it in GitHub Desktop.
Save bmaupin/80c7fd0fc81f234100fb61965e258ae9 to your computer and use it in GitHub Desktop.
Using buildah inside a RHEL container

Why

  • Unlike Docker, buildah doesn't need root privileges to run
  • Buildah can pass yum entitlements from build container to container being built
    • Since this has to be done manually (see /run/secrets:/run/secrets below) couldn't Docker do this as well?

Steps

  1. Make sure you're using a RHEL host registered with yum

  2. Make sure you're using RHEL build container image, such as:

    • registry.access.redhat.com/ubi7/ubi
    • registry.access.redhat.com/rhel7
  3. Install buildah in the build container

    # Override the default buildah storage driver; fixes "'overlay' is not supported over overlayfs" error
    export STORAGE_DRIVER=vfs
    # This is needed so that the yum entitlements from the build container end up in the container being built
    mkdir -p /etc/containers/; echo "/run/secrets:/run/secrets" >> /etc/containers/mounts.conf
    yum install -y --enablerepo=rhel-7-server-extras-rpms buildah
  4. Build the image using buildah

    buildah bud ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment