18.5. コンテナーでの Buildah の実行

この手順では、コンテナーで Buildah を実行し、イメージを基に作業コンテナーを作成する方法を説明します。

前提条件

  • container-tools メタパッケージがインストールされている。

手順

  1. registry.redhat.io レジストリーにログインします。

    $ podman login registry.redhat.io
    Username: myuser@mycompany.com
    Password: <password>
    Login Succeeded!
  2. registry.redhat.io/rhel9/buildah イメージをプルして実行します。

    # podman run --rm --device /dev/fuse -it \
      registry.redhat.io/rhel9/buildah /bin/bash
    • --rm オプションは、コンテナーの終了後に registry.redhat.io/rhel9/buildah イメージを削除します。
    • --device オプションは、ホストデバイスをコンテナーに追加します。
    • sys_chroot - 別のルートディレクトリーに変更する機能。コンテナーのデフォルト機能には含まれていません。
  3. registry.access.redhat.com/ubi9 イメージを使用して、新しいコンテナーを作成します。

    # buildah from registry.access.redhat.com/ubi9
    ...
    ubi9-working-container
  4. ubi9-working-container コンテナー内で ls / コマンドを実行します。

    # buildah run --isolation=chroot ubi9-working-container ls /
    bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv
  5. オプション: ローカルストレージ内のイメージをリスト表示します。

    # buildah images
    REPOSITORY                        TAG      IMAGE ID       CREATED       SIZE
    registry.access.redhat.com/ubi9   latest   ecbc6f53bba0   5 weeks ago   211 MB
  6. オプション: 作業用のコンテナーおよびそれらのベースイメージをリスト表示します。

    # buildah containers
    CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
    0aaba7192762     *     ecbc6f53bba0 registry.access.redhat.com/ub... ubi9-working-container
  7. オプション: registry.access.redhat.com/ubi9 イメージを registry.example.com にあるローカルレジストリーにプッシュします。

    # buildah push ecbc6f53bba0 registry.example.com:5000/ubi9/ubi