Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use yum inside Docker container running on CentOS

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)

like image 761
NateW Avatar asked Jun 30 '16 21:06

NateW


People also ask

Can you work inside a Docker container?

Once you have your Docker container up and running, you can work with the environment of the Docker container in the same way you would do with an Ubuntu machine. You can access the bash or shell of the container and execute commands inside it and play around with the file system.

Can I run Docker on CentOS?

To install Docker Engine, you need a maintained version of CentOS 7, CentOS 8 (stream), or CentOS 9 (stream). Archived versions aren't supported or tested. The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.

Which command is used for running the CentOS image as a container?

The Docker command is specific and tells the Docker program on the Operating System that something needs to be done. The run command is used to mention that we want to create an instance of an image, which is then called a container.


1 Answers

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.

like image 136
NateW Avatar answered Sep 21 '22 22:09

NateW