* Builder: correct the behavior of ADD when copying directories.

This commit is contained in:
Solomon Hykes 2013-06-19 14:26:11 -07:00
parent a056f1deec
commit 507ea757a5
2 changed files with 8 additions and 15 deletions

View File

@ -185,9 +185,9 @@ func CopyWithTar(src, dst string) error {
}
// Create the destination
var dstDir string
if dst[len(dst)-1] == '/' {
// The destination ends in /
// --> dst is the holding directory
if srcSt.IsDir() || dst[len(dst)-1] == '/' {
// The destination ends in /, or the source is a directory
// --> dst is the holding directory and needs to be created for -C
dstDir = dst
} else {
// The destination doesn't end in /

View File

@ -156,22 +156,15 @@ When a directory is copied or unpacked, it has the same behavior as 'tar -x': th
a) whatever existed at the destination path and b) the contents of the source tree, with conflicts resolved
in favor of b on a file-by-file basis.
If `<src>` is any other kind of file, it is copied individually along with its metadata.
If `<src>` is any other kind of file, it is copied individually along with its metadata. In this case,
if `<dst>` ends with a trailing slash '/', it will be considered a directory and the contents of `<src>`
will be written at `<dst>/base(<src>)`.
If `<dst>` does not end with a trailing slash, it will be considered a regular file and the contents
of `<src>` will be written at `<dst>`.
If `<dest>` doesn't exist, it is created along with all missing directories in its path. All new
files and directories are created with mode 0700, uid and gid 0.
If `<dest>` ends with a trailing slash '/', the contents of `<src>` is copied `inside` it.
For example "ADD foo /usr/src/" creates /usr/src/foo in the container. If `<dest>` already exists,
it MUST be a directory.
If `<dest>` does not end with a trailing slash '/', the contents of `<src>` is copied `over` it.
For example "ADD foo /usr/src" creates /usr/src with the contents of the "foo". If `<dest>` already
exists, it MUST be of the same type as the source.
3. Dockerfile Examples
======================