【问题标题】:Dockerfile Permission Denied when using yum install [duplicate]使用 yum install 时 Dockerfile 权限被拒绝 [重复]
【发布时间】:2021-03-07 10:37:13
【问题描述】:

我正在尝试从此图像创建 Dockerfile:https://hub.docker.com/r/centos/python-27-centos7

我的 Dockerfile:

FROM centos/python-27-centos7:latest

RUN yum install rpm-build -y

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt


CMD ["bash"]

但我得到了下一个错误:

 => ERROR [2/9] RUN yum install rpm-build -y                                                                                                                                0.6s
------                                                                                                                                                                           
 > [2/9] RUN yum install rpm-build -y:                                                                                                                                           
#5 0.480 Loaded plugins: fastestmirror, ovl                                                                                                                                      
#5 0.485 ovl: Error while doing RPMdb copy-up:
#5 0.485 [Errno 13] Permission denied: '/var/lib/rpm/Dirnames'
#5 0.579 You need to be root to perform this command.
------

我尝试添加 sudo 但仍然无法正常工作。 这里有什么问题?

【问题讨论】:

  • @SiHa 我不确定,因为然后yum install 安装到另一个目录...也许我需要通过 root 安装,然后替换一些二进制文件或添加到 PATH..
  • RUN chmod 0644 ?

标签: docker dockerfile centos7 rpm yum


【解决方案1】:

尝试使用root用户

    FROM centos/python-27-centos7:latest

    USER root
    RUN yum install rpm-build -y
    
    WORKDIR /usr/src/app
    
    COPY requirements.txt ./
    
    RUN pip install --no-cache-dir -r requirements.txt
    
    
    CMD ["bash"]

【讨论】:

    猜你喜欢
    • 2021-12-20
    • 2021-10-10
    • 2020-10-18
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多