fredrik
fredrik

Reputation: 10291

How to access local file when building from Dockerfile?

I need hello.rpm when I build from Dockerfile, but this rpm file is not available online.

Right now I'm serving the file by firing up a temporary web server, but ideally I'd like to run a build command which makes this local file available inside the container.

Is this possible?


My build command:

docker build -t fredrik/helloworld:1.0 .

My Dockerfile:

FROM centos:6
RUN rpm -ivh hello.rpm

Upvotes: 35

Views: 38572

Answers (2)

Eugenio
Eugenio

Reputation: 681

Otherwise if an internet connection is not a limiting factor while you're working just:

  1. Upload the file a cloud as Dropbox
  2. Go to your docker shell and wget https://www.cloudnameXYZ.com/filename

Upvotes: 1

Nicolas
Nicolas

Reputation: 2231

Why don't you COPY the file inside the container before executing RUN?

FROM centos:6
COPY hello.rpm /tmp/hello.rpm
RUN rpm -ivh /tmp/hello.rpm

This assumes that hello.rpm is next to your Dockerfile when you build it.

Upvotes: 56

Related Questions