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

后端 未结 4 1784
孤独总比滥情好
孤独总比滥情好 2021-02-02 13:56

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 th

相关标签:
4条回答
  • 2021-02-02 14:15

    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
    
    0 讨论(0)
  • 2021-02-02 14:18

    my Dockerfile constains these two lines:

    [...]
    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
    [...]
    

    Building image process fails with error "lstat SRC/kernel-3.10.0-327.13.1.el7.x86_64.rpm: no such file or directory"

    Both RPM files are inside "SRC" folder from where I'm running "docker build".

    What is the problem??

    Thanks.

    0 讨论(0)
  • 2021-02-02 14:19

    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
    
    0 讨论(0)
  • 2021-02-02 14:31

    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.

    0 讨论(0)
提交回复
热议问题