Qwertie
Qwertie

Reputation: 6493

Copy current directory in to docker image

When building my Docker image I need to copy all of the files in the same directory in to the Docker image.

I attempted to do this

ADD ./* $HOME/src

RUN ls $HOME/src

but it doesn't seem to work

ls: cannot access /root/src: No such file or directory

How would I go about copying all of the current directory and subdirectories in to my docker image while building?

Upvotes: 38

Views: 89483

Answers (2)

MB11
MB11

Reputation: 644

Just add / at the end of src in ADD statement.

ADD ./* $HOME/src/

Upvotes: 30

Qwertie
Qwertie

Reputation: 6493

I was building the images using docker build - < Dockerfile which apparently doen't send the build context so things can't be copied. After changing to docker build . and adding the / like MB11 suggested the build worked.

Upvotes: 23

Related Questions