最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

linux - How to install certain packages that are not available inside a container environment - Stack Overflow

matteradmin8PV0评论

I am working on tekton pipeline and I am trying to build my Dockerfile inside a running container (i.e., dind), but it's not able to find a few packages inside the container environment.

#No match for argument: lsscsi
#No match for argument: nvme-cli
#No match for argument: nfs-utils
#Dockerfile
FROM registry.access.redhat/ubi8/ubi-init

RUN yum -y update \
    && yum -y install \
              lsscsi \
              nvme-cli \
              net-tools

#Rest of Dockerfile

On the base container, I have enabled epel repo, attached redhat subscription and enabled few other repos, but still it does not work. I have written a script and execute this script before the docker build takes place

#!/bin/bash
subscription-manager register --username --password
subscription-manager attach
subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms
subscription-manager repos --enable rhel-8-for-$(arch)-baseos-rpms
subscription-manager repos --enable rhel-8-for-$(arch)-appstream-rpms
yum -y install .noarch.rpm

When I build this on rhel8 system, it uses the host's subscription and it is successfully able to install those packages, but only inside container env it fails. Is there some way I can work it to install inside a container? Also am I missing out enabling any ubi specific repos?

I am working on tekton pipeline and I am trying to build my Dockerfile inside a running container (i.e., dind), but it's not able to find a few packages inside the container environment.

#No match for argument: lsscsi
#No match for argument: nvme-cli
#No match for argument: nfs-utils
#Dockerfile
FROM registry.access.redhat/ubi8/ubi-init

RUN yum -y update \
    && yum -y install \
              lsscsi \
              nvme-cli \
              net-tools

#Rest of Dockerfile

On the base container, I have enabled epel repo, attached redhat subscription and enabled few other repos, but still it does not work. I have written a script and execute this script before the docker build takes place

#!/bin/bash
subscription-manager register --username --password
subscription-manager attach
subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms
subscription-manager repos --enable rhel-8-for-$(arch)-baseos-rpms
subscription-manager repos --enable rhel-8-for-$(arch)-appstream-rpms
yum -y install https://dl.fedoraproject./pub/epel/epel-release-latest-8.noarch.rpm

When I build this on rhel8 system, it uses the host's subscription and it is successfully able to install those packages, but only inside container env it fails. Is there some way I can work it to install inside a container? Also am I missing out enabling any ubi specific repos?

Share Improve this question asked Nov 18, 2024 at 18:08 DevOps__1903DevOps__1903 771 silver badge8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The issue occurs because the UBI8 container doesn't automatically use the same repositories as the host. To fix it, register the container with the Red Hat Subscription Manager using

subscription-manager register --username=<your_username> --password=<your_password> 

and attach the subscription with

subscription-manager attach

Then, enable the required repositories with

subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms --enable rhel-8-for-$(arch)-baseos-rpms --enable rhel-8-for-$(arch)-appstream-rpms

Finally, install EPEL inside the container using

 yum -y install https://dl.fedoraproject./pub/epel/epel-release-latest-8.noarch.rpm
Post a comment

comment list (0)

  1. No comments so far