无法在CentOS上运行的Docker容器中使用yum

时间:2016-06-30 21:51:58

标签: docker centos containers sudo yum

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

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命令前面,我会得到:

/bin/sh: sudo: command not found

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

底层发行版是CentOS Linux release 7.2.1511 (Core)

1 个答案:

答案 0 :(得分:36)

原来用户在基本影像中设置为jboss 当使用dockerfile命令USER root切换到root用户时,一切正常。