如何在构建docker实例时安装本地rpm文件?

时间:2015-05-06 16:39:29

标签: docker dockerfile

我有以下docker文件,我想专门安装我的磁盘上可用的rpm文件,因为我正在构建docker实例。我对rpm install的调用看起来像这样。命令 RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm失败了。

有没有办法在本地安装rpm文件到新的Docker实例?

FROM centos:latest
    RUN yum -y install yum-utils
    RUN yum -y install python-setuptools
    RUN easy_install supervisor
    RUN mkdir -p /var/log/supervisor
    RUN yum -y install which
    RUN yum -y install git
    # Basic build dependencies.
    RUN yum -y install  autoconf build-essential unzip zip
    # Gold linker is much faster than standard linker.
    RUN yum -y install  binutils
    # Developer tools.
    RUN yum -y install bash-completion curl emacs git man-db python-dev python-pip vim tar
    RUN yum -y install gcc gcc-c++ kernel-devel make
    RUN yum -y install swig
    RUN yum -y install wget
    RUN yum -y install python-devel
    RUN yum -y install ntp
    RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm

4 个答案:

答案 0 :(得分:22)

将此行放在rpm -i命令之前:

ADD /host/abs/path/to/chrpath-0.13-14.el7.x86_64.rpm /chrpath-0.13-14.el7.x86_64.rpm

然后你就可以了

RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm

答案 1 :(得分:4)

作为其他人在这里写的内容的补充和补充,而不是使用:

RUN rpm -i xyz.rpm

你可能会做得更好:

RUN yum localinstall -y xyz.rpm

后者具有以下优点:(a)它检查签名,(b)下载任何依赖项,以及(c)确保YUM知道包。最后一点不如其他两个重要,但它仍然值得。

答案 2 :(得分:3)

假设您在dict_weights = copy.deepcopy(combined_weights) for i in range(0, len(combined_weights[each_layer][:, 0, 0, 0])): for j in range(0, len(combined_weights[each_layer][0, :, 0, 0])): # Extract 5x5 trans_weight = combined_weights[each_layer][i,j] trans_weight = np.fliplr(np.flipud(trans_weight )) # Update dict_weights[each_layer][i, j] = trans_weight 处提供了Dockerfile,那么首先您需要将/opt/myproject/.置于rpm内,然后添加

/opt/myproject

答案 3 :(得分:0)

我的Dockerfile压缩了这两行:

[...]
ADD SRC/kernel-3.10.0-327.13.1.el7.x86_64.rpm  /tmp/kernel-3.10.0-327.13.1.el7.x86_64.rpm
ADD SRC/kernel-devel-3.10.0-327.13.1.el7.x86_64.rpm /tmp/kernel-devel-3.10.0-327.13.1.el7.x86_64.rpm
[...]

构建映像进程失败,错误" lstat SRC / kernel-3.10.0-327.13.1.el7.x86_64.rpm:没有这样的文件或目录"

两个RPM文件都位于" SRC"我正在运行的文件夹" docker build"。

问题是什么?

感谢。