9

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?

Saurabh
  • 882
  • 1
  • 5
  • 16
miketsui3a
  • 181
  • 1
  • 4
  • 14
  • 1
    Questions related to usage of programs are better suited for https://unix.stackexchange.com/ or https://serverfault.com/. – cyqsimon Nov 18 '19 at 03:53

3 Answers3

25

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
msuchy
  • 5,162
  • 1
  • 14
  • 26
16
  • 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
ali bouaziz
  • 161
  • 1
  • 3
10

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.

Sankar
  • 6,192
  • 12
  • 65
  • 89
  • nice, because they run most of the commands using root user but just before the last command, they do `USER 1000` – kakabali May 24 '20 at 15:38