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. zabbix的安装

    1  lamp环境搭建以及zabbix安装 方便的话使用yum方式(yum安装的是2.2版本) 安装epel环境 yum install -y epel-release 安装lamp环境 yum in ...

  2. 51nod 1060反素数

    经典题. #include<map> #include<queue> #include<stack> #include<cmath> #include& ...

  3. 一起学HTML基础-格式与布局fixed/absolute/relative/z-index/float

    很多网页都存在一个悬浮的操作条或者广告区,无论如何上下滚动网页,操作条或广告区都不会动,这个就是div制作,位置锁定在屏幕指定位置,现在我们就学习下网页的格式与布局. position 位置,来给di ...

  4. 用select实现监控终端输入

    首先,从man手册里找到对select函数的描述,如下: int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptf ...

  5. oracle11g 拆分字符串的详细技巧

    转自:http://m.blog.csdn.net/article/details?id=51946573 <-->功能需求                 有一个比较长的SQL语句,查询 ...

  6. 研华外触发实验PCI1714板卡安装事项

    1.安装在工控机中 研华的旧版本驱动和新版本的驱动文件不能同时安装,有冲突. 如何安装新版本: 卸载旧版本.控制面板中的device manager. 安装新版本的DAQ NAVI SDK文件,安装P ...

  7. 数据结构算法C语言实现(七)--- 3.1栈的线性实现及应用举例

    一.简述 栈,LIFO.是操作受限的线性表,和线性表一样有两种存储表示方法.下面以顺序存储为例,实现. 二.ADT 暂无. 三.头文件 //3_1.h /** author:zhaoyu email: ...

  8. JUnit报错:java.lang.ClassNotFoundException:

    只要把Java--------compiler-------building-------Buil path problems ------- incomplete build path 和 Circ ...

  9. linux安装Mac的默认Monaco字体

    Monaco字体是我最喜欢的编程字体,如果你想在linux上面安装,只需要在terminal中执行: curl -kL https://raw.github.com/cstrap/monaco-fon ...

  10. Linux运维工程师入门的10大实用工具

    说到工具,在行外可以说是技能,在行内我们一般称为工具,就是运维必须要掌握的工具. 我就大概列出这几方面,这样入门就基本没问题了. 工具如下: 1.Linux系统基础 这个不用说了,是基础中的基础,连这 ...