This error occurs when yum cannot find a requested package in its configured repositories during Docker builds on CentOS/RHEL-based images. The most common cause is that the package exists in a repository (like EPEL) that isn't enabled by default.
The "No package available" error appears when yum (Yellowdog Updater Modified), the package manager used in CentOS, RHEL, and Fedora-based Docker images, cannot locate a requested package in any of its configured repositories. Unlike Debian-based systems where packages are generally available in base repositories, many common packages on RHEL-based systems require enabling additional repositories like EPEL (Extra Packages for Enterprise Linux). This error is particularly common in Docker containers because base images ship with minimal repository configurations. Packages like nginx, htop, or many development tools aren't available in the base CentOS or RHEL repositories and require adding the EPEL repository or other third-party repos before installation.
Many common packages are only available in the EPEL (Extra Packages for Enterprise Linux) repository. Enable it first:
FROM centos:7
# ❌ WRONG - nginx not in base repos
RUN yum install -y nginx
# ✅ CORRECT - Enable EPEL first
RUN yum install -y epel-release && \
yum install -y nginxFor Rocky Linux or AlmaLinux (CentOS replacements):
FROM rockylinux:9
RUN dnf install -y epel-release && \
dnf install -y nginxThe epel-release package adds the EPEL repository configuration, making thousands of additional packages available.
If repositories are configured but packages still aren't found, clear the cache and refresh:
RUN yum clean all && \
yum makecache && \
yum install -y epel-release && \
yum install -y nginxOr in a single optimized layer:
RUN yum clean all && \
yum install -y epel-release && \
yum install -y nginx && \
yum clean all && \
rm -rf /var/cache/yumThe final cleanup reduces the image size by removing cached package files.
Package names differ between distributions. Search for the correct name:
# Run interactively to search for packages
docker run -it centos:7 bash
# Search for packages containing a keyword
yum search nginx
# List all available packages from EPEL
yum install -y epel-release
yum --disablerepo="*" --enablerepo="epel" list availableCommon package name differences:
| Debian/Ubuntu | CentOS/RHEL |
|---------------|-------------|
| apache2 | httpd |
| php | php |
| mysql-server | mariadb-server |
| libssl-dev | openssl-devel |
| build-essential | gcc make |
CentOS 7 and 8 have reached End-of-Life. Update repository URLs to use vault or archive mirrors:
For CentOS 7 (EOL July 2024):
FROM centos:7
# Update repo URLs to vault (archived)
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
# Now install packages
RUN yum install -y epel-release && \
yum install -y nginxFor EPEL 7 (archived):
RUN yum install -y https://archives.fedoraproject.org/pub/archive/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpmBetter approach: Migrate to actively maintained distributions like Rocky Linux 9, AlmaLinux 9, or Fedora.
For specific software, use the vendor's official repository instead of EPEL:
Nginx official repository:
FROM centos:7
# Add Nginx official repo
RUN echo '[nginx-stable]' > /etc/yum.repos.d/nginx.repo && \
echo 'name=nginx stable repo' >> /etc/yum.repos.d/nginx.repo && \
echo 'baseurl=http://nginx.org/packages/centos/$releasever/$basearch/' >> /etc/yum.repos.d/nginx.repo && \
echo 'gpgcheck=1' >> /etc/yum.repos.d/nginx.repo && \
echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo && \
echo 'gpgkey=https://nginx.org/keys/nginx_signing.key' >> /etc/yum.repos.d/nginx.repo
RUN yum install -y nginxNode.js from NodeSource:
RUN curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - && \
yum install -y nodejsIf using Amazon Linux 2, use the amazon-linux-extras command:
FROM amazonlinux:2
# Enable and install nginx
RUN amazon-linux-extras enable nginx1 && \
yum install -y nginx
# Or use the shorthand
RUN amazon-linux-extras install nginx1 -yFor Amazon Linux 2023, packages are available via dnf:
FROM amazonlinux:2023
RUN dnf install -y nginxAmazon Linux uses its own curated repositories rather than EPEL.
CentOS Stream vs CentOS Linux: CentOS Linux (7, 8) has reached EOL. CentOS Stream is a rolling-release distribution that sits upstream of RHEL. For production containers, consider Rocky Linux or AlmaLinux as drop-in CentOS replacements.
Repository priorities: When multiple repositories provide the same package, yum uses the yum-plugin-priorities package to determine which version to install. Lower priority numbers take precedence.
GPG keys: If you encounter GPG key errors, you can temporarily bypass verification (not recommended for production):
RUN yum install -y --nogpgcheck epel-releaseContainer-specific images: For nginx specifically, consider using the official nginx Docker image instead of installing on CentOS:
FROM nginx:alpine
# or
FROM nginx:1.25dnf vs yum: On CentOS 8+, RHEL 8+, Fedora, Rocky Linux, and AlmaLinux, dnf has replaced yum. While yum still works as an alias, prefer dnf for new Dockerfiles:
FROM rockylinux:9
RUN dnf install -y epel-release && dnf install -y nginxMinimal installations: Use yum install --setopt=tsflags=nodocs to skip documentation and reduce image size.
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker
Error response from daemon: failed to create the ipvlan port
How to fix 'failed to create the ipvlan port' in Docker
toomanyrequests: Rate exceeded for anonymous users
How to fix 'Rate exceeded for anonymous users' in Docker Hub