Skip to content

Commit

Permalink
dockerfile: add docs for --parents
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Mar 3, 2024
1 parent 6f8bd4c commit 2c9aba0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions frontend/dockerfile/docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,23 @@ COPY --parents ./x/a.txt ./y/a.txt /parents/
# /parents/y/a.txt
```

This behavior is analogous to the [Linux `cp` utility's](https://www.man7.org/linux/man-pages/man1/cp.1.html)
`--parents` flag.
This behavior is similar to the [Linux `cp` utility's](https://www.man7.org/linux/man-pages/man1/cp.1.html)
`--parents` or [`rsync`](https://man7.org/linux/man-pages/man1/rsync.1.html) `--relative` flag.

As with Rsync, it is possible to limit which parent directories are preserved by
inserting a dot and a slash (`./`) into the source path. If such point exists, only parent
directories after it will be preserved. This may be especially useful copies between stages
with `--from` where the source paths need to be absolute.

```dockerfile
# syntax=docker/dockerfile-upstream:master-labs
FROM scratch

COPY --parents ./x/./y/*.txt /parents/

# /parents/y/a.txt
# /parents/y/b.txt
```

Note that, without the `--parents` flag specified, any filename collision will
fail the Linux `cp` operation with an explicit error message
Expand Down

0 comments on commit 2c9aba0

Please sign in to comment.