Skip to content

Conversation

@matejvasek
Copy link
Contributor

@matejvasek matejvasek commented Nov 13, 2025

This reverts commit 2b848cc.

The commit's assumption that copyUIDGID=true means that UID/GID from the tar should be preserved does not seem to be true. Opposite is true: if copyUIDGUID=true the main UID/GID of the container is used. I tested this on moby.

Also brief look at the source code seems to confirm this:
https://github.com/moby/moby/blob/16880e9e1ba21593215b40241d62c043410e0ae7/daemon/archive_unix.go#L136-L144
https://github.com/moby/moby/blob/16880e9e1ba21593215b40241d62c043410e0ae7/daemon/archive_tarcopyoptions_unix.go#L22-L30

Yes it's quite contra-intuitive but it does behave that way.

See this issue opened since 2017 moby/moby#34096

Now, docker cp hostfile container:containerpath will copy a file from the host to the container but preserving the original uid/gid (with the respective mapping to the container). docker cp -a hostfile container:containerpath (as defined in the documentation) is meant to "copy all uid/gid information" but it is in fact setting the uid and gid to the main user inside the container.

Also apparently there was a PR to fix this moby/moby#34099 but is has newer been merged.

And another bug report docker/docs#17533 that suggest to change in documentation instead of the behaviour.

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

None

@openshift-ci openshift-ci bot added the do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None label Nov 13, 2025
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Nov 13, 2025
@matejvasek
Copy link
Contributor Author

/cc @giuseppe @Honny1

@openshift-ci openshift-ci bot requested review from Honny1 and giuseppe November 13, 2025 21:47
@matejvasek matejvasek force-pushed the revert-copyuidgid-inversion branch from 616bcd5 to 6fa5f70 Compare November 13, 2025 22:00
@matejvasek
Copy link
Contributor Author

/cc @dwaynebradley

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 13, 2025

@matejvasek: GitHub didn't allow me to request PR reviews from the following users: dwaynebradley.

Note that only containers members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @dwaynebradley

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@matejvasek
Copy link
Contributor Author

I assume this does not need release notes, since the reverted commit has not been added to any release branch yet.

@matejvasek
Copy link
Contributor Author

/cc @TomSweeneyRedHat

@openshift-ci openshift-ci bot added release-note-none and removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Nov 13, 2025
@Honny1
Copy link
Member

Honny1 commented Nov 14, 2025

I am not sure what to do about this. The Docker documentation says one thing, but the software actually does another. Breaking other tools is also not good.

Docker rest API reference

@Luap99
Copy link
Member

Luap99 commented Nov 14, 2025

I am not sure what to do about this. The Docker documentation says one thing, but the software actually does another. Breaking other tools is also not good.

Well the compat API is supposed to be docker compatible, so it should do what docker does not what docker docs say it does. As a general rule if there are users depending on the behavior then it is much easier to keep such behavior working and update the docs instead of breaking the users, especially since there would be no good way for them to handle this because the option suddenly does the opposite so they would need to version check and invert the param which is just ugly as hell.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but as general rule can you add the context of these things also in the commit message please. I prefer to read the git log with context and not have to go to github for every commit to figure out why it was done.

@matejvasek
Copy link
Contributor Author

moby/moby#51523

@matejvasek
Copy link
Contributor Author

@Luap99 I could force push amended message if you wish.

This reverts commit 2b848cc.

The official Docker API documentation was misleading here.
Testing shown that old podman behaviour was correct.
In docker copyUIDGID=true means that primary container uid/gid is used,
not the uid/gid from the tar stream.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
@matejvasek matejvasek force-pushed the revert-copyuidgid-inversion branch from 6fa5f70 to 65411d5 Compare November 14, 2025 11:40
@matejvasek
Copy link
Contributor Author

I guess the reverted commit has not been merged to any of the release branches, right?

@matejvasek
Copy link
Contributor Author

When it comes to cherry-picking to releases, is there somebody to we should notify to not include the reverted commit in backports?

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 14, 2025
@Honny1
Copy link
Member

Honny1 commented Nov 14, 2025

LGTM. Let's await the Moby maintainers' response in the discussion. I will then update the documentation based on their answer.

@Luap99
Copy link
Member

Luap99 commented Nov 14, 2025

When it comes to cherry-picking to releases, is there somebody to we should notify to not include the reverted commit in backports?

We don't have a process for that. Your comments on the original PR should be enough for others looking at it to not backport it I suppose

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 14, 2025
@matejvasek
Copy link
Contributor Author

matejvasek commented Nov 14, 2025

OK tried to look on the original issue #27332 and talk to the reporter of it.

It appears that he did really observe inconsistency with docker behaviour.
But the difference was not the parameter inversion.

The flag works same way on podman/docker, with exception when used with a container with no explicit user.
In docker the flag/param is ineffectual for such a containers and uid/gid form tar are always used.
The podman simply assumes root user and acts accordingly.

See #27538

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 14, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, Luap99, matejvasek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit ec2567e into containers:main Nov 14, 2025
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants