且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Docker如何在不将其提交到映像的情况下添加文件?

更新时间:2022-11-03 10:38:30

根据文档,如果您从本地文件系统(而非URL)添加到Dockerfile中(带有目标路径,而不是路径+文件名),它将把文件解压缩到给定的目录中。

According to the documentation, if you pass an archive file from the local filesystem (not a URL) to ADD in the Dockerfile (with a destination path, not a path + filename), it will uncompress the file into the directory given.


如果< src>是本地tar归档文件,且压缩格式为
(身份,gzip,bzip2或xz),则将其解压缩为目录。
来自远程URL的资源未解压缩。复制或解压缩目录
时,其行为与tar -x相同:结果为
,并集为:

If <src> is a local tar archive in a recognized compression format (identity, gzip, bzip2 or xz) then it is unpacked as a directory. Resources from remote URLs are not decompressed. When a directory is copied or unpacked, it has the same behavior as tar -x: the result is the union of:

1)目标路径上存在的任何内容;以及2)
源树的内容,已解决冲突以支持 2。

1) Whatever existed at the destination path and 2) The contents of the source tree, with conflicts resolved in favor of "2." on a file-by-file basis.

尝试:

ADD /files/apache-stratos.zip /opt/

看看文件是否在那里,而无需进一步解压缩。

and see if the files are there, without further decompression.