Skip to content

Commit

Permalink
docs: clarify leading and trailing slashes in add/copy source path
Browse files Browse the repository at this point in the history
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
  • Loading branch information
dvdksn committed Jan 15, 2025
1 parent cac225d commit d55dd67
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions frontend/dockerfile/docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
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
Expand Down

0 comments on commit d55dd67

Please sign in to comment.