Crystal
Crystal

Reputation: 29458

Cannot open RPM, skipping in Dockerfile

I'm trying to create a Dockerfile to build our reusable image. What I have so far is

FROM crystaltwix/centos-mono
MAINTAINER crystaltwix

ADD ./rpms/MyRpm.rpm ./rpms
RUN yum --nogpgcheck localinstall ./rpms/MyRpm.rpm

I get an error that says

Cannot open: ./rpms/Myrpm.rpm.  Skipping.

What I don't understand why it doesn't work is, if I do run the image in my container:

sudo docker run -i -t -v /home/crystaltwix/projects/rpms:/opt/rpms crystaltwix/centos-mono /bin/bash

Then in the shell of my container, I do the same command:

yum --nogpgcheck localinstall ./rpms/MyRpm.rpm

This works fine. It just doesn't work within my Dockerfile. Am I missing something specific about the way Dockerfile builds images?

Upvotes: 1

Views: 4559

Answers (1)

FaerAnne
FaerAnne

Reputation: 66

From https://docs.docker.com/reference/builder/#add: If <src> is any other kind of file, it is copied individually along with its metadata. In this case, if <dest> ends with a trailing slash /, it will be considered a directory and the contents of <src> will be written at <dest>/base(<src>).

ADD ./rpms/MyRpm.rpm ./rpms results in ./rpms being the MyRpm.rpm file. Try ADD ./rpms/MyRpm.rpm ./rpms/ instead.

Upvotes: 1

Related Questions