Can't use yum inside Docker container running on CentOS

29,385

Turns out the user was set to jboss in the base image.
When is switched to user root with the dockerfile command USER root everything worked.

Share:
29,385
NateW
Author by

NateW

Updated on July 27, 2022

Comments

  • NateW
    NateW almost 2 years

    I am unable to run any yum commands inside my Docker container without getting the following error:

    ovl: Error while doing RPMdb copy-up:
    [Errno 13] Permission denied: '/var/lib/rpm/Group'
    You need to be root to perform this command.
    

    I'm confused because I'm pretty sure docker containers are run with the default user root. Still, if I try putting sudo in front of a yum install -y <package> or yum update -y command I get:

    /bin/sh: sudo: command not found
    

    I'm using the following base image so I can easily run a Java Wildfly application inside Docker: https://hub.docker.com/r/jboss/wildfly/

    The underlying distro is CentOS Linux release 7.2.1511 (Core)

  • Marcello de Sales
    Marcello de Sales about 6 years
    Got this running centos/nodejs-6-centos7... What a shame!
  • Drew
    Drew over 4 years
    Ditto on centos/python-36-centos7
  • cryanbhu
    cryanbhu over 3 years
    after switching to root to perform yum step, should you change it back to the original user? In your case jboss
  • NateW
    NateW almost 3 years
    Yeah, switching to ROOT is likely a security concern. Check out this thread for better docker user management: stackoverflow.com/a/48957722/4447761