run-in-node-container: support rootless mode#25841
run-in-node-container: support rootless mode#25841k8s-ci-robot merged 1 commit intokubernetes:masterfrom
Conversation
run-in-node-container is used for javascript "rollup", so the tools running in the container produce files which must be owned by the user on the host. To achieve this, the docker run --user option is used to ensure that the tools in the container are run as host user. However, with rootless mode - apparently in both docker and podman, but I'm using podman - a user namespace is used and users in the container are mapped to a range of users on the host. This means that if we run a command as root in the container, this corresponds to the host user. When we specify --user, this results in a different host user being used. There are apparently two ways of achieving what we want - not using --user so that the commands run as root in the container, which is mapped to the desired host user. Or we can use --userns keep-id which means a 1:1 user mapping is used, and the user specified by --user corresponds to the same user on the host. The former seems more like how you'd typically use this mode. And so we detect rootless mode using "docker system info", and avoid the --user flag in this case. Podman reports "rootless: (true|false)", whereas docker just includes a "rootless" keyword. For more on this, see: https://www.redhat.com/sysadmin/user-flag-rootless-containers https://docs.docker.com/engine/security/rootless pre-commit/pre-commit#1243 pre-commit/pre-commit#1484 (Note: all of the above applies even without SELinux and was tested with "setenforce 0")
|
Hi @markmc. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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/test-infra repository. |
|
I have only tested this with rootless podman. I'll try to test with docker soon, unless someone else wants to! It should be sufficient to just run: and check /hold |
|
/ok-to-test |
Or ... maybe CI will do it for me? lol From /unhold |
|
/approve thanks Mark! |
|
/assign @stevekuznetsov @BenTheElder |
BenTheElder
left a comment
There was a problem hiding this comment.
/lgtm
/approve
FYI @chaodaiG
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BenTheElder, chaodaiG, dims, markmc The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
run-in-node-containeris used for javascript "rollup", so the tools running in the container produce files which must be owned by the user on the host.To achieve this, the
docker run --useroption is used to ensure that the tools in the container are run as host user.However, with rootless mode - apparently in both docker and podman, but I'm using podman - a user namespace is used and users in the container are mapped to a range of users on the host. This means that if we run a command as root in the container, this corresponds to the host user. When we specify
--user, this results in a different host user being used.There are apparently two ways of achieving what we want - not using
--userso that the commands run as root in the container, which is mapped to the desired host user. Or we can use--userns keep-idwhich means a 1:1 user mapping is used, and the user specified by--usercorresponds to the same user on the host. The former seems more like how you'd typically use this mode.And so we detect rootless mode using
docker system info, and avoid the--userflag in this case.Podman reports
rootless: (true|false), whereas docker just includes arootlesskeyword.For more on this, see:
https://www.redhat.com/sysadmin/user-flag-rootless-containers
https://docs.docker.com/engine/security/rootless
pre-commit/pre-commit#1243
pre-commit/pre-commit#1484
(Note: all of the above applies even without SELinux (see #25798) and was tested with "setenforce 0")