无法在CentOS上运行的Docker容器内使用yum [英] Can't use yum inside Docker container running on CentOS

查看:1170
本文介绍了无法在CentOS上运行的Docker容器内使用yum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Docker容器中运行任何yum命令,而不会出现以下错误:

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.

我很困惑,因为我非常确定docker容器是使用默认用户root运行的。不过,如果我尝试将sudo放在 yum install -y< package> yum update -y 前面我得到的命令:

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

我正在使用以下基本映像,因此我可以在Docker中轻松运行Java Wildfly应用程序: https://hub.docker.com/r/jboss/wildfly/

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/

底层发行版是 CentOS Linux版本7.2.1511(核心)

推荐答案

在基础映像中将用户设置为 jboss

使用dockerfile命令切换到用户root时。 USER root 一切正常。

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.

这篇关于无法在CentOS上运行的Docker容器内使用yum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆