Skip to content

Commit 78bcf8d

Browse files
authored
Merge pull request #5664 from dvdksn/tidy-dockerfile-add-copy-localsrc
docs: clarify leading and trailing slashes in add/copy source path
2 parents a617d0e + d55dd67 commit 78bcf8d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

frontend/dockerfile/docs/reference.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -1280,11 +1280,11 @@ relative to the build context. For example, if the build context is the current
12801280
directory, `ADD file.txt /` adds the file at `./file.txt` to the root of the
12811281
filesystem in the build container.
12821282

1283-
When adding source files from the build context, their paths are interpreted as
1284-
relative to the root of the context. If you specify a relative path leading
1285-
outside of the build context, such as `ADD ../something /something`, parent
1286-
directory paths are stripped out automatically. The effective source path in
1287-
this example becomes `ADD something /something`.
1283+
Specifying a source path with a leading slash or one that navigates outside the
1284+
build context, such as `ADD ../something /something`, automatically removes any
1285+
parent directory navigation (`../`). Trailing slashes in the source path are
1286+
also disregarded, making `ADD something/ /something` equivalent to `ADD
1287+
something /something`.
12881288

12891289
If the source is a directory, the contents of the directory are copied,
12901290
including filesystem metadata. The directory itself isn't copied, only its
@@ -1556,11 +1556,14 @@ For more information about copying from named sources, see the
15561556

15571557
#### Copying from the build context
15581558

1559-
When copying source files from the build context, their paths are interpreted as
1560-
relative to the root of the context. If you specify a relative path leading
1561-
outside of the build context, such as `COPY ../something /something`, parent
1562-
directory paths are stripped out automatically. The effective source path in
1563-
this example becomes `COPY something /something`.
1559+
When copying source files from the build context, paths are interpreted as
1560+
relative to the root of the context.
1561+
1562+
Specifying a source path with a leading slash or one that navigates outside the
1563+
build context, such as `COPY ../something /something`, automatically removes
1564+
any parent directory navigation (`../`). Trailing slashes in the source path
1565+
are also disregarded, making `COPY something/ /something` equivalent to `COPY
1566+
something /something`.
15641567

15651568
If the source is a directory, the contents of the directory are copied,
15661569
including filesystem metadata. The directory itself isn't copied, only its

0 commit comments

Comments
 (0)