Subodh Nijsure
Subodh Nijsure

Reputation: 3453

How to install a local rpm file when building docker instance?

I have following docker file, I want to specifically install a rpm file that is available on my disk as I am building docker instance. My invocation of rpm install looks like this. Command RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm fails.

Is there a way to install rpm file available locally to new Docker instance?

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

Upvotes: 18

Views: 76294

Answers (3)

Keith Gaughan
Keith Gaughan

Reputation: 22675

As and addendum to what others have written here, rather than using:

RUN rpm -i xyz.rpm

You might be better off doing this:

RUN yum install -y xyz.rpm

The latter has the advantages that (a) it checks the signature, (b) downloads any dependencies, and (c) makes sure YUM knows about the package. This last bit is less important than the other two, but it's still worthwhile.

Upvotes: 11

amit srivastava
amit srivastava

Reputation: 51

Suppose you have your Dockerfile available at /opt/myproject/. Then first you have to put rpm inside /opt/myproject and then add

Add /xyz.rpm /xyz.rpm

RUN rpm -i xyz.rpm

Upvotes: 5

Vitaly Isaev
Vitaly Isaev

Reputation: 5805

Put this line before your rpm -i command:

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

Then you'll be able to do

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

Upvotes: 30

Related Questions