22.3. runlabel を使用した support-tools の実行
組み込みの runlabel を使用して、support-tools コンテナーをデプロイします。この方法は、定義済みコマンドをイメージに直接使用することで、インストール、実行、削除を単純化します。
rhel10/support-tools コンテナーイメージは、support-toolsd デーモンのコンテナー化されたバージョンを実行するために作成されます。support-tools イメージには、install、run、uninstall という runlabel が含まれています。
前提条件
-
container-toolsメタパッケージがインストールされている。
手順
support-toolsイメージをプルします。# podman pull registry.redhat.io/rhel10/support-toolssupport-toolsのinstallrunlabel を表示します。# podman container runlabel install --display rhel10/support-tools command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel10/support-tools:latest -e NAME=support-tools registry.redhat.io/rhel10/support-tools:latest /bin/install.shこれは、このコマンドがホストに特権を付与し、コンテナー内の
/hostにホストの root ファイルシステムをマウントして、install.shスクリプトを実行することを示しています。support-toolsのinstallrunlabel を実行します。# podman container runlabel install rhel10/support-tools command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel10/support-tools:latest -e NAME=support-tools registry.redhat.io/rhel10/support-tools:latest /bin/install.sh Creating directory at /host//etc/pki/support-tools Creating directory at /host//etc/support-tools.d Installing file at /host//etc/support-tools.conf Installing file at /host//etc/sysconfig/support-tools Installing file at /host//etc/logrotate.d/syslogこれにより、
support-toolsイメージが後で使用するファイルがホストシステム上に作成されます。support-toolsのrunrunlabel を表示します。# podman container runlabel run --display rhel10/support-tools command: podman run -d --privileged --name support-tools --net=host --pid=host -v /etc/pki/support-tools:/etc/pki/support-tools -v /etc/support-tools.conf:/etc/support-tools.conf -v /etc/sysconfig/support-tools:/etc/sysconfig/support-tools -v /etc/support-tools.d:/etc/support-tools.d -v /var/log:/var/log -v /var/lib/support-tools:/var/lib/support-tools -v /run:/run -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -e IMAGE=registry.redhat.io/rhel10/support-tools:latest -e NAME=support-tools --restart=always registry.redhat.io/rhel10/support-tools:latest /bin/support-tools.shこのコマンドは、ホストに特権を提供し、
support-toolsdデーモンを実行するためにsupport-toolsコンテナーを起動する際に、ホストから特定のファイルとディレクトリーをコンテナー内にマウントします。support-toolsのrunrunlabel を実行します。# podman container runlabel run rhel10/support-tools command: podman run -d --privileged --name support-tools --net=host --pid=host -v /etc/pki/support-tools:/etc/pki/support-tools -v /etc/support-tools.conf:/etc/support-tools.conf -v /etc/sysconfig/support-tools:/etc/sysconfig/support-tools -v /etc/support-tools.d:/etc/support-tools.d -v /var/log:/var/log -v /var/lib/support-tools:/var/lib/support-tools -v /run:/run -v /etc/machine-id:/etc/machine-id -v /etc/localtime:/etc/localtime -e IMAGE=registry.redhat.io/rhel10/support-tools:latest -e NAME=support-tools --restart=always registry.redhat.io/rhel10/support-tools:latest /bin/support-tools.sh 28a0d719ff179adcea81eb63cc90fcd09f1755d5edb121399068a4ea59bd0f53support-toolsコンテナーは権限を開き、ホストから必要なものをマウントし、support-toolsdデーモンをバックグラウンドで実行します (-d)。support-toolsdデーモンはログメッセージの収集を開始し、メッセージを/var/logディレクトリー内のファイルに送信します。support-toolsのuninstallrunlabel を表示します。# podman container runlabel uninstall --display rhel10/support-tools command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel10/support-tools:latest -e NAME=support-tools registry.redhat.io/rhel10/support-tools:latest /bin/uninstall.shsupport-toolsのuninstallrunlabel を実行します。# podman container runlabel uninstall rhel10/support-tools command: podman run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=registry.redhat.io/rhel10/support-tools:latest -e NAME=support-tools registry.redhat.io/rhel10/support-tools:latest /bin/uninstall.sh注記この場合、
uninstall.shスクリプトは、/etc/logrotate.d/syslogファイルを削除します。設定ファイルはクリーンアップされません。