-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: clarify leading and trailing slashes in add/copy source path #5664
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1280,11 +1280,11 @@ relative to the build context. For example, if the build context is the current | |
directory, `ADD file.txt /` adds the file at `./file.txt` to the root of the | ||
filesystem in the build container. | ||
|
||
When adding source files from the build context, their paths are interpreted as | ||
relative to the root of the context. If you specify a relative path leading | ||
outside of the build context, such as `ADD ../something /something`, parent | ||
directory paths are stripped out automatically. The effective source path in | ||
this example becomes `ADD something /something`. | ||
Specifying a source path with a leading slash or one that navigates outside the | ||
build context, such as `ADD ../something /something`, automatically removes any | ||
parent directory navigation (`../`). Trailing slashes in the source path are | ||
also disregarded, making `ADD something/ /something` equivalent to `ADD | ||
something /something`. | ||
|
||
If the source is a directory, the contents of the directory are copied, | ||
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 | |
|
||
#### Copying from the build context | ||
|
||
When copying source files from the build context, their paths are interpreted as | ||
relative to the root of the context. If you specify a relative path leading | ||
outside of the build context, such as `COPY ../something /something`, parent | ||
directory paths are stripped out automatically. The effective source path in | ||
this example becomes `COPY something /something`. | ||
When copying source files from the build context, paths are interpreted as | ||
relative to the root of the context. | ||
|
||
Specifying a source path with a leading slash or one that navigates outside the | ||
build context, such as `COPY ../something /something`, automatically removes | ||
any parent directory navigation (`../`). Trailing slashes in the source path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the example you gave, does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dvdksn Any chance you could add this clarification to the updated document? Here is what the updated version would look like:
|
||
are also disregarded, making `COPY something/ /something` equivalent to `COPY | ||
something /something`. | ||
|
||
If the source is a directory, the contents of the directory are copied, | ||
including filesystem metadata. The directory itself isn't copied, only its | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we document somewhere that for the destination the path may be resolved relative to the WORKDIR that's set, so if it's a relative path (I think) we resolve it relative to the active WORKDIR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like we describe that too well... only indirectly. I guess we could do with a bit more clarity there too. I can do a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, never mind me. We do describe it. I'm just bad at reading documentation.