http://blog.163.com/digoal@126/blog/static/163877040201410341236664/
 
在Dockerfile中, 我们可以使用ADD和COPY拷贝文件(注意是上下文相关目录的文件, 不是本地的任意文件, 除非上下文目录是根)到container制作image.
那么两者有什么区别呢?
 
ADD 多了2个功能, 下载URL和解压.  其他都一样.
如果你不希望压缩文件拷贝到container后会被解压的话, 那么使用COPY.
如果需要自动下载URL并拷贝到container的话, 请使用ADD.
 
  • If <src> is a URL and <dest> does not end with a trailing slash, then a file is downloaded from the URL and copied to <dest>.

  • If <src> is a URL and <dest> does end with a trailing slash, then the filename is inferred from the URL and the file is downloaded to <dest>/<filename>. For instance, ADD http://example.com/foobar / would create the file /foobar. The URL must have a nontrivial path so that an appropriate filename can be discovered in this case (http://example.com will not work).

  • 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. 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.
[参考]

Docker Dockerfile COPY vs ADD的更多相关文章

  1. docker Dockerfile指令ADD和COPY的区别,添加目录方法

    docker Dockerfile指令ADD和COPY的区别,添加目录方法 ADD指令的功能是将主机构建环境(上下文)目录中的文件和目录.以及一个URL标记的文件 拷贝到镜像中.其格式是: ADD 源 ...

  2. 【Docker】涨姿势,深入了解Dockerfile 中的 COPY 与 ADD 命令

    参考资料:https://www.cnblogs.com/sparkdev/p/9573248.html Dockerfile 中提供了两个非常相似的命令 COPY 和 ADD,本文尝试解释这两个命令 ...

  3. docker(11)Dockerfile 中的COPY与ADD 命令

    前言 Dockerfile 中提供了两个非常相似的命令 COPY 和 ADD,本文尝试解释这两个命令的基本功能,以及其异同点,然后总结其各自适合的应用场景. Build 上下文的概念 在使用 dock ...

  4. Dockerfile 中的 COPY 与 ADD 命令

    Dockerfile 中提供了两个非常相似的命令 COPY 和 ADD,本文尝试解释这两个命令的基本功能,以及其异同点,然后总结其各自适合的应用场景. Build 上下文的概念 在使用 docker ...

  5. docker~Dockerfile方式生成控制台和Api项目的镜像

    回到目录 一些理论知识 将控制台程序和API程序部署到docker,然后运行它,这个首先要解决的问题就是如何在linux平台运行C#代码,哈哈,很古老的问题,事实上,对于这种问题早在几年前就已经有了解 ...

  6. Docker Dockerfile指令

    Docker 可以通过 Dockerfile 的内容来自动构建镜像.Dockerfile 是一个包含创建镜像所有命令的文本文件,通过docker build命令可以根据 Dockerfile 的内容构 ...

  7. Docker Dockerfile 一

    1.概述 创建Docker镜像的方式有三种 docker commit命令:由容器生成镜像: Dockerfile文件+docker build命令: 从本地文件系统导入:OpenVZ的模板. 关于这 ...

  8. Docker Dockerfile简述

    原文地址:https://www.cnblogs.com/cuimiemie/p/6442677.html 作用 Dockerfile的内容是一坨可以执行的代码(或者说是指令)(docker的DSL) ...

  9. Docker Dockerfile 定制镜像(转)

    转自: https://yeasy.gitbooks.io/docker_practice/ 及 https://blog.csdn.net/wo18237095579/article/details ...

随机推荐

  1. 引入AOP 报错 error at ::0 formal unbound in pointcut

    使用了AOP 后启动报错 九月 27, 2016 2:29:46 下午 org.springframework.context.support.AbstractApplicationContext r ...

  2. bzoj1012

    Description 现在请求你维护一个数列,要求提供以下两种操作:1. 查询操作.语法:Q L 功能:查询当前数列中末尾L 个数中的最大的数,并输出这个数的值.限制:L不超过当前数列的长度.2. ...

  3. NPOI导出模板样式

    /// <summary> /// 导出多种车辆统计表格 /// </summary> /// <returns></returns> [ActionN ...

  4. Centering, Scaling and Normalizing

    Centering: 使数据的均值(Empirical Mean)变为0的过程. 具体操作:原始数据Xn(n=1, 2, 3, ..., n)减去均值. Scaling: 使数据的标准差(Empiri ...

  5. iOS 下ARC的内存管理机制

    本文来源于我个人的ARC学习笔记,旨在通过简明扼要的方式总结出iOS开发中ARC(Automatic Reference Counting,自动引用计数)内存管理技术的要点,所以不会涉及全部细节.这篇 ...

  6. tableView使用的易忘技术点(相对于自己)

    1.在tableView设置右向导航指示箭头 cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 2.tableView的系 ...

  7. 【poj3122】 Pie

    http://poj.org/problem?id=3122 (题目链接) 题意 给出N个pie的半径和F个friend,每个friend得到的pie必须一样,求每个人能得到的pie的最大大小. so ...

  8. css选择器([class*=" icon-"], [class^=icon-] 的区别)

    官方解释: [attribute^=value],a[src^="https"],选择其 src 属性值以 "https" 开头的每个 <a> 元素 ...

  9. asp.net项目发布打包研究

    有几种思路: 1.[推荐]直接发布,然后手动打包成压缩包,需要的时候直接上传到服务器,或者在本地解压出来手动上传到虚拟空间(支持绝大多数的虚拟空间,自由度高,DZ也是采用这样的打包,FTP上传操作比较 ...

  10. Jenkins参数化构建插件,实现构建前输入自定义参数

    插件: [Build with Parameters]:https://wiki.jenkins-ci.org/display/JENKINS/Build+With+Parameters+Plugin ...