22.3. 使用 runlabels 运行 support-tools
使用其内置 runlabels 部署 support-tools 容器。此方法通过使用镜像中直接定义的命令来简化安装、执行和删除过程。
制作 rhel10/support-tools 容器镜像的目的是为了运行 support-toolsd 守护进程的容器化版本。support-tools 镜像包含以下 runlabels:install、run 和 uninstall。
先决条件
-
container-tools元数据包已安装。
流程
拉取
support-tools镜像:# podman pull registry.redhat.io/rhel10/support-tools显示
support-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,并运行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-tools容器时,将主机中的特定文件和目录挂载到容器内,以运行support-toolsd守护进程。对
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.sh为
support-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文件。它不会清理配置文件。