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

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

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.


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