DNF Install Fails in Container: Unknown Repo Error on RHEL Systems

Solution Verified - Updated -

Issue

  • During a container build on RHEL systems, the following dnf command is used to install packages from RHEL repositories"
dnf install --enablerepo=rhel-8-for-x86_64-appstream-rpms \
  --installroot=$mnt --nodocs --setopt=install_weak_deps=false \
  --setopt=reposdir=/etc/yum.repos.d <pkg>
  • And it fails with the following error, even though the repository is available on the host:
Updating Subscription Management repositories.
Unable to read consumer identity
subscription-manager is operating in container mode.
Error: Unknown repo: 'rhel-8-for-x86_64-appstream-rpms'

Environment

  • RHEL 8.0
  • Container image build inside buildah container

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content