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

查看:72
本文介绍了无法在 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 release 7.2.1511 (Core)

推荐答案

原来用户在基础镜像中设置为 jboss.
当使用 dockerfile 命令 USER root 切换到用户 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天全站免登陆