Dockerfile to download a file using wget to current directory and copy the downloaded file to another directory

Hi,

I have written a docker file to download a file from some link using wget and to copy that file to another location as below:

FROM ubuntu:12.04

MAINTAINER Name

RUN wget /test.war

COPY test.war /testfolder

When I build the dockerfile, the file is being saved, but I am not able to see the downloaded file. Hence the COPY step also fails. Below is the output:

‘test.war’ saved [1024/1024]

e[0m —> ea3c32991879
Removing intermediate container 1623d7805c67
Step 4 : COPY test.war /testfolder
lstat : test.war no such file or directory

Please help me resolving this issue.

COPY (like ADD) tries to copy from OUTSIDE the image INTO the image.

as the file is downloaded INSIDE the image already by wget, you need to use the commandline cp command

RUN cp test.war /testfolder

you could also avoid having it twice, and use the move command

RUN mv test.war /testfolder