Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: Rootless Podman-in-Podman on WSL#27412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dvorst wants to merge2 commits intocontainers:main
base:main
Choose a base branch
Loading
fromdvorst:fix/rootless-podman-in-podman-on-wsl

Conversation

@dvorst
Copy link

@dvorstdvorst commentedOct 30, 2025
edited
Loading

Fixes:#27411

pkg/machine/wsl/declares.go

Adjust SUB_UID and SUB_GID ranges to support running rootless Podman inside a rootless run Podman container.

By default, a new user is assigned the following sub-ID ranges:
SUB_UID_MIN=100000, SUB_GID_MIN=100000, SUB_UID_COUNT=65536, SUB_GID_COUNT=65536
This means the user’s sub-UID and sub-GID ranges are 100000–165535.

When the container is run rootless by the user in WSL, ID mappings occur as follows:

  • Container ID 0 (root) maps to user ID 1000 on the host (user in WSL).
  • Container IDs 1–65536 map to IDs 100000–165535 on host (the subid range previously mentioned).

If a new user is created inside this container (to build containers for example), it will attempt to use the default sub-ID range (100000–165535). However, this exceeds the container’s available ID mapping, since only IDs up to 65536 are mapped, causing rootless PinP to fail.

To enable container-in-container builds, the sub-ID ranges for the user in WSL must be large enough to provide at least 65536 usable IDs. A minimum SUB_UID_COUNT and SUB_GID_COUNT of 165536 is thus required, but 200000 is used here to provide additional margin.

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, usegit commit -s --amend). The author email must match
    the sign-off email address. SeeCONTRIBUTING.md
    for more information.
  • Referenced issues usingFixes: #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 passmake validatepr (format/lint checks)
  • Release note entered in the section below (orNone if no user-facing changes)

Does this PR introduce a user-facing change?

Fixed Rootless Podman-in-Podman on WSL, by sufficiently increasing the SUB_GID and SUB_UID range of the user on WSL (#27411).

@openshift-ci
Copy link
Contributor

[APPROVALNOTIFIER] This PR isNOT APPROVED

This pull-request has been approved by:dvorst
Once this PR has been reviewed and has the lgtm label, please assigntomsweeneyredhat for approval. For more information seethe Code Review Process.

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

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

@dvorstdvorstforce-pushed thefix/rootless-podman-in-podman-on-wsl branch fromdd60c4b to9c4dbb1CompareOctober 30, 2025 20:35
@packit-as-a-service
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@baude
Copy link
Member

i think you should add a test to the PR that validates your change; otherwise, if we change how the image is built or someone makes an unknowing chnage, you could easily have a regression. wdyt ?

also thanks for your diligence on this this PR.

otherwise, this LGTM

@dvorst
Copy link
Author

Sure, I can add a test. Had a quick look at the tests dir but it isn't clear to me at first sight where I should place it. Can you point me in the right direction? Maybe there are already tests that I can use to start from

@TomSweeneyRedHat
Copy link
Member

@dvorst thanks for the PR!
If@baude says differently, go with his thinking. Otherwise the machine tests live in./pkg/machine/e2e

@TomSweeneyRedHat
Copy link
Member

And code LGTM too

@dvorstdvorstforce-pushed thefix/rootless-podman-in-podman-on-wsl branch 7 times, most recently frome998a89 to3772effCompareNovember 3, 2025 09:55
closes:containers#27411Adjust SUB_UID and SUB_GID ranges to support running rootless Podman inside a rootless run Podman container.By default, a new user is assigned the following sub-ID ranges:  SUB_UID_MIN=100000, SUB_GID_MIN=100000, SUB_UID_COUNT=65536, SUB_GID_COUNT=65536This means the user’s sub-UID and sub-GID ranges are 100000–165535.When the container is run rootless with the user defined below, ID mappings occur as follows:- Container ID 0 (root) maps to user ID 1000 on the host (which is the user created below).- Container IDs 1–65536 map to IDs 100000–165535 on host (the subid range previously mentioned).If a new user is created inside this container (to build containers for example), it willattempt to use the default sub-ID range (100000–165535). However, this exceeds the container’savailable ID mapping, since only IDs up to 65536 are mapped. This causes nested rootless Podmanto fail.To enable container-in-container builds, the sub-ID ranges for the user must be large enoughto provide at least 65536 usable IDs. A minimum SUB_UID_COUNT and SUB_GID_COUNT of 165536 isrequired, but 200000 is used here to provide additional margin.Signed-off-by: dvorst <87502756+dvorst@users.noreply.github.com>
@dvorstdvorstforce-pushed thefix/rootless-podman-in-podman-on-wsl branch 7 times, most recently fromd702dfc to67371a5CompareNovember 3, 2025 18:00
in pkg/machine/e2e/init_test.goSigned-off-by: dvorst <87502756+dvorst@users.noreply.github.com>
Copy link
Member

@Luap99Luap99 left a comment

Choose a reason for hiding this comment

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

You need to rebase your PR to pass the search failure in the integration tests (not related to your code).

And please squash both commits into one, we prefer code and test in the same commits.

Comment on lines +41 to +42
sed -ir 's/SUB_UID_COUNT.*/SUB_UID_COUNT 200000/' /etc/login.defs
sed -ir 's/SUB_GID_COUNT.*/SUB_GID_COUNT 200000/' /etc/login.defs
Copy link
Member

Choose a reason for hiding this comment

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

This is fixing this differently on WSL than compared to our providers which only set a range for the one user we create by writing subuid/subgid directly. So I would rather match that.

subUID:=100000
subUIDs:=1000000
ifuid>=subUID&&uid< (subUID+subUIDs) {
subUID=uid+1
}
etcSubUID:=fmt.Sprintf(`%s:%d:%d`,usrName,subUID,subUIDs)

In particular they use a range of1000000 uids not200000 which I think is important to keep the behaviours consistent between providers

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the intermediate review.

I'll change the count to1 000 000 instead of200 000. I’m quite busy with work at the moment, but I might have time to work on this around Christmas.

I'll also modify/etc/subuid and/etc/subgid directly, right after the adduser command is run, to align it with theignition.go script.

My initial approach was based on the fact that adduser doesn’t provide an option to configure the sub-ID ranges, so these had to be set in a different way. Changing the defaults seemed to be a cleaner approach than modifying subuid/subgid directly, since that will give issues if adduser/useradd behavior ever changes (though i don't think that will ever change without backwards compatibility).

Comment on lines +128 to +143
It("init subid range check for rootless PinP",func() {
/* By default, a new user is assigned the following sub-ID ranges (see manual useradd):
* SUB_UID_MIN=100000, SUB_GID_MIN=100000, SUB_UID_COUNT=65536, SUB_GID_COUNT=65536
* This means the default sub-UID and sub-GID ranges are 100000–165535.
*
* When the container is run rootless by the user in WSL, ID mappings occur as follows:
* Container ID 0 (root) maps to user ID on the host.
* Container IDs 1–65536 map to IDs 100000–165535 on host (range previously mentioned).
*
* If a new user is created inside the container and used to build containers with
* (rootless PinP), it will attempt to use the default sub-ID range (100000–165535). Given
* the mapping, this means that the host must at least have a SUB_UID_COUNT and
* SUB_GID_COUNT of 165536. Since 165536 would only allow rootless PinP for the first
* user (with ID 1000), the check is run against a count of 166536 (=165536+1000) as to
* provide additional margin.
*/
Copy link
Member

Choose a reason for hiding this comment

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

rootless PinP is not really relevant to this test at all, it could just be called check subuid/gid ranges.

But in any case adding new test cases is quite slow as they all require new Vm to be created. As such I would strongly advise to not a a new It() block for something simple as this. Instead just add a new ssh command at the end ofsimple init with username for example

Copy link
Author

Choose a reason for hiding this comment

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

The end goal is to fix rootles PinP, but i'll make a batch script as you suggest instead.

Comment on lines +156 to +162
ifsshSession.ExitCode()!=0 {
Fail(fmt.Sprintf("SSH session failed with exit code %d\nstdout:\n%s\nstderr:\n%s",
sshSession.ExitCode(),
sshSession.outputToString(),
sshSession.errorToString(),
))
}
Copy link
Member

Choose a reason for hiding this comment

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

That doesn't add anything so please don't do that.

Copy link
Author

@dvorstdvorstNov 20, 2025
edited
Loading

Choose a reason for hiding this comment

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

I was hoping I could create the test without having to set everything up locally. The test is failing at this point so i was hoping to print out more information to the log, without success though. It seems I have to set up everything locally, which will require resetting the podman machine as what I could tell, which is a bit cumbersome for me as I need it for work. Hopefully I have time for this around Christmas. I was not planning on leaving this in once all tests succeed

Comment on lines +171 to +181
// A user must exist in order to run podman rootless, a line in both subuid and subgid
// should exist for it, so 2 lines in total.
Expect(len(counts)).To(BeNumerically(">=",2),"expected at least 1 user/line in /etc/subuid and /etc/subgid each, got %d",len(counts))

// Verify the count. At the moment only 1 user is created in the machine. If multiple users
// are ever created, this will check that all users have a sufficient subid range.
for_,count:=rangecounts {
n,err:=strconv.Atoi(count[1])
Expect(err).ToNot(HaveOccurred())
Expect(n).To(BeNumerically(">=",count_min),"expected last number %d to be >= %d",n,count_min)
}
Copy link
Member

Choose a reason for hiding this comment

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

There should be no reason to harden that for multiple user we only ever create one and should not create multiple. If that ever were to be the case we can adapt tests later. For now I don't see the value in complicating the check for this.

Copy link
Author

Choose a reason for hiding this comment

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

There is a count for the user and group id, so there will be a for loop anyway. The comment is meant to be informative for if a second user is ever created, and that this test will basically be run for all users.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Luap99Luap99Luap99 left review comments

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug: Rootless Podman-in-Podman on WSL

4 participants

@dvorst@baude@TomSweeneyRedHat@Luap99

[8]ページ先頭

©2009-2025 Movatter.jp