yum install -y: Packages on RHEL 7 and CentOS
yum install -y installs packages non-interactively on older RPM systems like RHEL 7, CentOS 7, and Amazon Linux 2.
On newer distros dnf replaced yum, but many long-lived CI images still run yum. The flags are close cousins of dnf.
What it does
yum install resolves and installs the named packages plus dependencies from the enabled repositories. -y assumes yes to prompts. On RHEL 8+ yum is a symlink to dnf, so the same command works, but RHEL 7 uses the original yum.
Common usage
yum install -y git curl ca-certificates
# enable an extra repo for one command
yum install -y --enablerepo=epel htop
# shrink the image
yum clean all && rm -rf /var/cache/yumOptions
| Flag | What it does |
|---|---|
| -y / --assumeyes | Answer yes to all prompts |
| --enablerepo / --disablerepo <id> | Toggle a repo for this command |
| --nogpgcheck | Skip GPG signature checks (avoid in prod) |
| --setopt=<opt>=<val> | Override a yum config option |
| yum clean all | Clear cached metadata and packages |
In CI
CentOS 7 reached end of life, so its default mirrors return errors; point baseurl at vault.centos.org in the repo files before installing. Run yum clean all and remove /var/cache/yum in the same layer to keep images small.
Common errors in CI
"No package <X> available" means the package or its repo is missing; enable the right repo (EPEL, etc.). "Could not retrieve mirrorlist ... [Errno 14]" on CentOS 7 usually means the EOL mirrors are gone; switch to vault.centos.org. "Cannot find a valid baseurl for repo" is the same class of problem. "Public key for <pkg> is not installed" means the GPG key is missing; rpm --import it.