Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I cannot install yum in my docker container

Tags:

docker

rpm

yum

rhel

I have a docker container which was built by a keycloak image.

I want to install vim in the container but I found that I need to have yum in order to install the vim. I tried to download yum from the internet and use rpm to install it, but the container didn't have sudo to let me change the file permission.

Following is my linux version:

NAME="Red Hat Enterprise Linux"
VERSION="8.0 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.0"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.0 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.0:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.0
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.0" 

How can I get any text editor installed in the container?

like image 640
miketsui3a Avatar asked Nov 18 '19 03:11

miketsui3a


People also ask

Can I install anything in docker container?

To install packages in a docker container, the packages should be defined in the Dockerfile. If you want to install packages in the Container, use the RUN statement followed by exact download command . You can update the Dockerfile with latest list of packages at anytime and build again to create new image out of it.


3 Answers

Minimal RHEL 8 containers do not contain Yum (or DNF) because that requires Python, which inflates the size of an image quite a bit. However, it contains microdnf which is written in C and which has limited capabilities.

You should be able to do

microdnf install vim

or

microdnf install yum
like image 144
msuchy Avatar answered Oct 22 '22 23:10

msuchy


  • connect as a root to your container:
docker exec -u root -it <container> bash

*then install vim (or what you need) with

microdnf install vim
like image 43
ali bouaziz Avatar answered Oct 22 '22 21:10

ali bouaziz


I ran into the same problem and found a solution. In your Dockerfile, Try:

FROM jboss/keycloak:8.0.1
USER root
RUN microdnf install <whatever>

HTH.

like image 9
Sankar Avatar answered Oct 22 '22 22:10

Sankar