How to fix No package nginx available in Docker

DockerBEGINNERMEDIUMUpdated Dec 6, 2025· 193 views

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.

Quick fix

Fixes No package nginx available

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 nginx
  1. Enable EPEL repository before installing packages
  2. Clean yum cache and update repository metadata
  3. Verify package name and search for alternatives
  4. Fix archived repository URLs for EOL distributions
docker — error
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 nginx
No package nginx available

What this error means

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.

Typical symptoms

  • Build fails with 'No package <package-name> available'
  • yum install commands succeed on host but fail in Dockerfile
  • Error appears even for common packages like nginx, htop, or nodejs
  • Package installs fine on Ubuntu but fails on CentOS-based images
  • Message 'Nothing to do' appears after the error

Common causes

  1. Package exists in EPEL repository which isn't enabled by default
  2. Package name differs between distributions (e.g., httpd vs apache2)
  3. Repository URLs are outdated or unreachable (especially for EOL CentOS versions)
  4. Package is not available for the specific architecture or OS version
  5. Repository is configured but disabled in yum.repos.d configuration
  6. Network connectivity or DNS issues preventing repository access

How to fix "No package nginx available"

1Enable EPEL repository before installing packages

Many common packages are only available in the EPEL (Extra Packages for Enterprise Linux) repository. Enable it first:

dockerfile
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 nginx

For Rocky Linux or AlmaLinux (CentOS replacements):

dockerfile
FROM rockylinux:9

RUN dnf install -y epel-release && \
    dnf install -y nginx

The epel-release package adds the EPEL repository configuration, making thousands of additional packages available.

2Clean yum cache and update repository metadata

If repositories are configured but packages still aren't found, clear the cache and refresh:

dockerfile
RUN yum clean all && \
    yum makecache && \
    yum install -y epel-release && \
    yum install -y nginx

Or in a single optimized layer:

dockerfile
RUN yum clean all && \
    yum install -y epel-release && \
    yum install -y nginx && \
    yum clean all && \
    rm -rf /var/cache/yum

The final cleanup reduces the image size by removing cached package files.

3Verify package name and search for alternatives

Package names differ between distributions. Search for the correct name:

bash
# 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 available

Common package name differences:
| Debian/Ubuntu | CentOS/RHEL |
|---------------|-------------|
| apache2 | httpd |
| php | php |
| mysql-server | mariadb-server |
| libssl-dev | openssl-devel |
| build-essential | gcc make |

4Fix archived repository URLs for EOL distributions

CentOS 7 and 8 have reached End-of-Life. Update repository URLs to use vault or archive mirrors:

For CentOS 7 (EOL July 2024):

dockerfile
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 nginx

For EPEL 7 (archived):

dockerfile
RUN yum install -y https://archives.fedoraproject.org/pub/archive/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm

Better approach: Migrate to actively maintained distributions like Rocky Linux 9, AlmaLinux 9, or Fedora.

5Install from official package repositories

For specific software, use the vendor's official repository instead of EPEL:

Nginx official repository:

dockerfile
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 nginx

Node.js from NodeSource:

dockerfile
RUN curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - && \
    yum install -y nodejs
6Use Amazon Linux extras for AWS-based images

If using Amazon Linux 2, use the amazon-linux-extras command:

dockerfile
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 -y

For Amazon Linux 2023, packages are available via dnf:

dockerfile
FROM amazonlinux:2023

RUN dnf install -y nginx

Amazon Linux uses its own curated repositories rather than EPEL.

Advanced notes

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):

dockerfile
RUN yum install -y --nogpgcheck epel-release

Container-specific images: For nginx specifically, consider using the official nginx Docker image instead of installing on CentOS:

dockerfile
FROM nginx:alpine
# or
FROM nginx:1.25

dnf 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:

dockerfile
FROM rockylinux:9
RUN dnf install -y epel-release && dnf install -y nginx

Minimal installations: Use yum install --setopt=tsflags=nodocs to skip documentation and reduce image size.

Frequently asked questions

What does "No package nginx available" mean?
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.
How do I fix "No package nginx available"?
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.
What causes "No package nginx available"?
Package exists in EPEL repository which isn't enabled by default Package name differs between distributions (e.g., httpd vs apache2) Repository URLs are outdated or unreachable (especially for EOL CentOS versions)
Is the "No package nginx available" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading