Skip to content

Commit 2d7373a

Browse files
committed
Fix incorrect documentation for docker cp -a flag
The `-a` (`--archive`) flag description claimed "Archive mode (copy all uid/gid information)" which is misleading. In practice: - Without `-a` (default): `docker cp` preserves ownership (uid/gid) from the source - With `-a`: ownership is set to match the container user (as configured with `--user`) The old documentation described the opposite of the actual behavior, as reported in #6870. Updated the flag description in the Go source, markdown docs, and fish shell completions to accurately reflect the behavior. Closes #6870
1 parent 538ee85 commit 2d7373a

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

cli/command/container/cp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ container source to stdout.`,
159159

160160
flags := cmd.Flags()
161161
flags.BoolVarP(&opts.followLink, "follow-link", "L", false, "Always follow symbol link in SRC_PATH")
162-
flags.BoolVarP(&opts.copyUIDGID, "archive", "a", false, "Archive mode (copy all uid/gid information)")
162+
flags.BoolVarP(&opts.copyUIDGID, "archive", "a", false, "Archive mode (set ownership to match the container user)")
163163
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress progress output during copy. Progress output is automatically suppressed if no terminal is attached")
164164
return cmd
165165
}

contrib/completion/fish/docker.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from commit' -a '(__fish_pri
169169

170170
# cp
171171
complete -c docker -f -n '__fish_docker_no_subcommand' -a cp -d "Copy files/folders between a container and the local filesystem"
172-
complete -c docker -A -f -n '__fish_seen_subcommand_from cp' -s a -l archive -d 'Archive mode (copy all uid/gid information)'
172+
complete -c docker -A -f -n '__fish_seen_subcommand_from cp' -s a -l archive -d 'Archive mode (set ownership to match the container user)'
173173
complete -c docker -A -f -n '__fish_seen_subcommand_from cp' -s L -l follow-link -d 'Always follow symbol link in SRC_PATH'
174174
complete -c docker -A -f -n '__fish_seen_subcommand_from cp' -l help -d 'Print usage'
175175

docs/reference/commandline/container_cp.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ container source to stdout.
1616

1717
| Name | Type | Default | Description |
1818
|:----------------------|:-------|:--------|:-------------------------------------------------------------------------------------------------------------|
19-
| `-a`, `--archive` | `bool` | | Archive mode (copy all uid/gid information) |
19+
| `-a`, `--archive` | `bool` | | Archive mode (set ownership to match the container user) |
2020
| `-L`, `--follow-link` | `bool` | | Always follow symbol link in SRC_PATH |
2121
| `-q`, `--quiet` | `bool` | | Suppress progress output during copy. Progress output is automatically suppressed if no terminal is attached |
2222

@@ -41,12 +41,10 @@ relative paths as relative to the current working directory where `docker cp` is
4141
run.
4242

4343
The `cp` command behaves like the Unix `cp -a` command in that directories are
44-
copied recursively with permissions preserved if possible. Ownership is set to
45-
the user and primary group at the destination. For example, files copied to a
46-
container are created with `UID:GID` of the root user. Files copied to the local
47-
machine are created with the `UID:GID` of the user which invoked the `docker cp`
48-
command. However, if you specify the `-a` option, `docker cp` sets the ownership
49-
to the user and primary group at the source.
44+
copied recursively with permissions preserved if possible. By default, ownership
45+
(uid/gid) of the copied files is preserved from the source. If you specify the
46+
`-a` option, `docker cp` sets the ownership to match the user and primary group
47+
of the container (as configured with `--user`).
5048
If you specify the `-L` option, `docker cp` follows any symbolic link
5149
in the `SRC_PATH`. `docker cp` doesn't create parent directories for
5250
`DEST_PATH` if they don't exist.

docs/reference/commandline/cp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ container source to stdout.
1616

1717
| Name | Type | Default | Description |
1818
|:----------------------|:-------|:--------|:-------------------------------------------------------------------------------------------------------------|
19-
| `-a`, `--archive` | `bool` | | Archive mode (copy all uid/gid information) |
19+
| `-a`, `--archive` | `bool` | | Archive mode (set ownership to match the container user) |
2020
| `-L`, `--follow-link` | `bool` | | Always follow symbol link in SRC_PATH |
2121
| `-q`, `--quiet` | `bool` | | Suppress progress output during copy. Progress output is automatically suppressed if no terminal is attached |
2222

0 commit comments

Comments
 (0)