Can't use yum inside Docker container running on CentOS

DockerCentosContainersSudoYum

Docker Problem Overview


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)

Docker Solutions


Solution 1 - Docker

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNateWView Question on Stackoverflow
Solution 1 - DockerNateWView Answer on Stackoverflow