... | ... |
@@ -185,9 +185,9 @@ func CopyWithTar(src, dst string) error { |
185 | 185 |
} |
186 | 186 |
// Create the destination |
187 | 187 |
var dstDir string |
188 |
- if dst[len(dst)-1] == '/' { |
|
189 |
- // The destination ends in / |
|
190 |
- // --> dst is the holding directory |
|
188 |
+ if srcSt.IsDir() || dst[len(dst)-1] == '/' { |
|
189 |
+ // The destination ends in /, or the source is a directory |
|
190 |
+ // --> dst is the holding directory and needs to be created for -C |
|
191 | 191 |
dstDir = dst |
192 | 192 |
} else { |
193 | 193 |
// The destination doesn't end in / |
... | ... |
@@ -156,22 +156,15 @@ When a directory is copied or unpacked, it has the same behavior as 'tar -x': th |
156 | 156 |
a) whatever existed at the destination path and b) the contents of the source tree, with conflicts resolved |
157 | 157 |
in favor of b on a file-by-file basis. |
158 | 158 |
|
159 |
-If `<src>` is any other kind of file, it is copied individually along with its metadata. |
|
159 |
+If `<src>` is any other kind of file, it is copied individually along with its metadata. In this case, |
|
160 |
+if `<dst>` ends with a trailing slash '/', it will be considered a directory and the contents of `<src>` |
|
161 |
+will be written at `<dst>/base(<src>)`. |
|
162 |
+If `<dst>` does not end with a trailing slash, it will be considered a regular file and the contents |
|
163 |
+of `<src>` will be written at `<dst>`. |
|
160 | 164 |
|
161 | 165 |
If `<dest>` doesn't exist, it is created along with all missing directories in its path. All new |
162 | 166 |
files and directories are created with mode 0700, uid and gid 0. |
163 | 167 |
|
164 |
-If `<dest>` ends with a trailing slash '/', the contents of `<src>` is copied `inside` it. |
|
165 |
-For example "ADD foo /usr/src/" creates /usr/src/foo in the container. If `<dest>` already exists, |
|
166 |
-it MUST be a directory. |
|
167 |
- |
|
168 |
-If `<dest>` does not end with a trailing slash '/', the contents of `<src>` is copied `over` it. |
|
169 |
-For example "ADD foo /usr/src" creates /usr/src with the contents of the "foo". If `<dest>` already |
|
170 |
-exists, it MUST be of the same type as the source. |
|
171 |
- |
|
172 |
- |
|
173 |
- |
|
174 |
- |
|
175 | 168 |
3. Dockerfile Examples |
176 | 169 |
====================== |
177 | 170 |
|