Oracle linux8在安装docker的时候提示filtered out by modular filtering

来自三线的随记

错误提示诸如下述的基本都与dnf(yum) module 机制有关

All matches were filtered out by modular filtering for argument: ${package_name}
- package ${package_name} is filtered out by modular filtering

现象:

在配置好docker-ce repo后,执行yum install docker-ce出现了一大堆报错

[root@test yum.repos.d]# yum install docker-ce
Last metadata expiration check: 0:06:38 ago on Thu 08 Sep 2022 06:12:42 PM CST.
Error:
 Problem: package docker-ce-3:20.10.17-3.el8.x86_64 requires container-selinux >= 2:2.74, but none of the providers can be installed
  - cannot install the best candidate for the job
  - package container-selinux-2:2.107-2.module+el8.1.0+5440+994fc847.noarch is filtered out by modular filtering

可以看到时依赖包container-selinux因为某些filter原因安装不上

解决流程:

enable / disable related modules

首先可以看一下这个package是由哪个module提供的

yum module provides container-selinux

找到相应的Module名字以后,如container-tools 就需要执行命令看看对应的module状态

[root@test yum.repos.d]# yum module list container-tools
Last metadata expiration check: 0:09:02 ago on Thu 08 Sep 2022 06:12:42 PM CST.
Oracle Linux 8 Application Stream (x86_64)
Name            Stream     Profiles Summary
container-tools ol8 [d][x] common [ Most recent (rolling) versions of podman, buildah, skopeo, runc, conmon, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested t
                           d]       ogether, and updated as frequently as every 12 weeks.
container-tools 1.0 [x]    common [ Stable versions of podman 1.0, buildah 1.5, skopeo 0.1, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and supp
                           d]       orted for 24 months.
container-tools 2.0 [x]    common [ Stable versions of podman 1.6, buildah 1.11, skopeo 0.1, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and sup
                           d]       ported for 24 months.
container-tools 3.0 [x]    common [ Stable versions of podman 3.0, buildah 1.19, skopeo 1.2, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and sup
                           d]       ported for 24 months.
container-tools 4.0 [x]    common [ Stable versions of podman 4.0, buildah 1.24, skopeo 1.6, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and sup
                           d]       ported for 24 months.

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

可以看出这里因为某些原因默认的container-tools ol8 module被禁用了,启用一下即可正常继续操作

yum module enable container-tools

参数绕过module filter限制

doc: https://dnf.readthedocs.io/en/latest/modularity.html#hotfix-repositories

doc from man dnf:

   Modular Filtering
       Please see the modularity documentation for details on how
       Modular Filtering works.

       With modularity, only RPM packages from active module streams are
       included in the available package set. RPM packages from inactive
       module streams, as well as non-modular packages with the same
       name or provides as a package from an active module stream, are
       filtered out. Modular filtering is not applied to packages added
       from the command line, installed packages, or packages from
       repositories with module_hotfixes=true in their .repo file.

       Disabling of modular filtering is not recommended, because it
       could cause the system to get into a broken state. To disable
       modular filtering for a particular repository, specify
       module_hotfixes=true in the .repo file or use
       --setopt=<repo_id>.module_hotfixes=true.

       To discover the module which contains an excluded package use dnf
       module provides.

如果对涉及的module进行各种enable / disable 都没帮助的话,可以对相应的repo添加参数绕过module filter限制,例如:

先找出对应package所在的仓库

[root@test yum.repos.d]# yum info container-selinux
Last metadata expiration check: 0:11:27 ago on Thu 08 Sep 2022 06:12:42 PM CST.
Available Packages
Name         : container-selinux
Epoch        : 2
Version      : 2.188.0
Release      : 1.module+el8.6.0+20721+d8d917a9
Architecture : src
Size         : 56 k
Source       : None
Repository   : ol8_appstream
Summary      : SELinux policies for container runtimes
URL          : https://github.com/containers/container-selinux
License      : GPLv2
Description  : SELinux policy modules for use with container runtimes.

修改相应的repo配置,添加参数module_hotfixes=True即可

[root@test yum.repos.d]# cat /etc/yum.repos.d/oracle-linux-ol8.repo
[ol8_appstream]
name=Oracle Linux 8 Application Stream ($basearch)
baseurl=https://yum$ociregion.oracle.com/repo/OracleLinux/OL8/appstream/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
module_hotfixes=True