在Docker文件中,我使用wget下载图像中的文件。但是当我在docker-compose文件中使用此图像时,容器不包含文件...
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"]
在容器中我有/ blast文件夹,但不是文件......我知道如何做一个wget并保存文件?为什么他们会消失?
修改
泊坞历史
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
docker-compose build(提取部分)的输出
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
答案 0 :(得分:5)
将你的RUN分组,在一个RUN中执行wget和tar,比如
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
查看编写Dockerfile的最佳实践
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
并在Dockerfile中使用ENV而不是export