In a Docker file I use wget to download file in the image. But when I use this image in a docker-compose file, the container doesn't contains the files...
FROM debian:8
RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /blast && cd /blast
RUN wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.6.0+-x64-linux.tar.gz
RUN tar zxvpf ncbi-blast-2.6.0+-x64-linux.tar.gz && rm ncbi-blast-2.6.0+-x64-linux.tar.gz
RUN export PATH=$PATH:/blast/ncbi-blast-2.6.0+/bin
#&& export BLASTDB=/blast/blastdb
CMD ["sleep", "infinity"]
In the container I've the /blast folder, but not the files... Someon know how I can do a wget and keep files ? And why they disappear ?
EDIT
The docker history
IMAGE CREATED CREATED BY SIZE COMMENT
13361cc1dda8 9 minutes ago /bin/sh -c #(nop) CMD ["sleep" "infinity"] 0 B
748afb9b0a0a 9 minutes ago /bin/sh -c #(nop) WORKDIR /blast 0 B
6eb2b58af7d4 9 minutes ago /bin/sh -c export PATH=$PATH:/blast/ncbi-b... 0 B
1331a22dcf67 10 minutes ago /bin/sh -c wget ftp://ftp.ncbi.nlm.nih.gov... 675 MB
83d2844843e5 35 minutes ago /bin/sh -c mkdir -p /blast && cd /blast 0 B
6b0b6a13ae47 41 minutes ago /bin/sh -c apt-get update && apt-get insta... 41.2 MB
054abe38b1e6 12 hours ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 12 hours ago /bin/sh -c #(nop) ADD file:712c48086043553... 123 MB
The output of docker-compose build (extract part)
2017-04-25 07:41:47 (10.1 MB/s) - 'ncbi-blast-2.6.0+-x64-linux.tar.gz' saved [222504398]
ncbi-blast-2.6.0+/
ncbi-blast-2.6.0+/ChangeLog
ncbi-blast-2.6.0+/LICENSE
ncbi-blast-2.6.0+/ncbi_package_info
ncbi-blast-2.6.0+/doc/
ncbi-blast-2.6.0+/doc/README.txt
ncbi-blast-2.6.0+/bin/
ncbi-blast-2.6.0+/bin/makeblastdb
ncbi-blast-2.6.0+/bin/tblastx
ncbi-blast-2.6.0+/bin/tblastn
ncbi-blast-2.6.0+/bin/blastn
ncbi-blast-2.6.0+/bin/blastdb_aliastool
ncbi-blast-2.6.0+/bin/update_blastdb.pl
ncbi-blast-2.6.0+/bin/windowmasker
ncbi-blast-2.6.0+/bin/psiblast
ncbi-blast-2.6.0+/bin/blastx
ncbi-blast-2.6.0+/bin/rpsblast
ncbi-blast-2.6.0+/bin/segmasker
ncbi-blast-2.6.0+/bin/blastdbcheck
ncbi-blast-2.6.0+/bin/rpstblastn
ncbi-blast-2.6.0+/bin/deltablast
ncbi-blast-2.6.0+/bin/makembindex
ncbi-blast-2.6.0+/bin/convert2blastmask
ncbi-blast-2.6.0+/bin/blastp
ncbi-blast-2.6.0+/bin/dustmasker
ncbi-blast-2.6.0+/bin/makeprofiledb
ncbi-blast-2.6.0+/bin/blastdbcmd
ncbi-blast-2.6.0+/bin/legacy_blast.pl
ncbi-blast-2.6.0+/bin/blast_formatter
ncbi-blast-2.6.0+/README
---> 1331a22dcf67
Removing intermediate container 06070bb79e70
Dockerfile to download a file using wget to current directory and copy the downloaded file to another directory.
According to the documentation: The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile. If the WORKDIR doesn't exist, it will be created even if it's not used in any subsequent Dockerfile instruction.
The best way is to put the Dockerfile inside the empty directory and then add only the application and configuration files required for building the docker image. To increase the build's performance, you can exclude files and directories by adding a . dockerignore file to that directory as well.
group your RUN, do the wget and the tar in one RUN, something like
RUN wget ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/ncbi-blast-2.6.0+-x64-linux.tar.gz \
&& tar zxvpf ncbi-blast-2.6.0+-x64-linux.tar.gz && rm ncbi-blast-2.6.0+-x64-linux.tar.gz
See the best practices for writing Dockerfile
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
and use ENV instead of export in your Dockerfile
https://docs.docker.com/engine/reference/builder/#env
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With