Fix docker cp success message to report actual content size instead of tar stream size #6800
Open
4RH1T3CT0R7 wants to merge 1 commit intodocker:masterfrom
Open
Fix docker cp success message to report actual content size instead of tar stream size #68004RH1T3CT0R7 wants to merge 1 commit intodocker:masterfrom
4RH1T3CT0R7 wants to merge 1 commit intodocker:masterfrom
Conversation
Signed-off-by: 4RH1T3CT0R7 <iprintercanon@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5777
Description
docker cp currently reports the TAR archive stream size in its "Successfully copied" message. Because TAR format adds headers and 512-byte block padding, this
is always larger than the actual content. For example, copying an empty file reports "Successfully copied 1.54kB" instead of "0B", which is misleading.
For copyFromContainer: the container API already returns PathStat.Size with the exact file size, so we use that directly for regular files. For directories,
Stat.Size only gives the directory entry size (not contents), so we fall back to the tar stream size as the best available approximation.
For copyToContainer: we compute the actual content size from the local filesystem before creating the tar archive. For files this is the file size; for
directories it's the sum of all regular file sizes. If the size computation fails for any reason, we fall back to the tar stream size.
The live progress indicator is unchanged and still shows tar stream throughput, which is the correct metric during transfer.