Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Ignore userns=keep-id in rootful mode, instead of erroring out #17337

Closed
imphil opened this issue Feb 2, 2023 · 3 comments · Fixed by #17350
Closed

[Feature]: Ignore userns=keep-id in rootful mode, instead of erroring out #17337

imphil opened this issue Feb 2, 2023 · 3 comments · Fixed by #17350
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@imphil
Copy link
Contributor

imphil commented Feb 2, 2023

Feature request description

Currently, specifying --userns=keep-id in podman run results in a hard error:

$ sudo podman run --userns=keep-id alpine echo hi
Error: keep-id is only supported in rootless mode

Setting the PODMAN_USERNS=keep-id environment variable has the same effect.

I'm in the process of setting up a reusable VS Code Dev container, where I can specify docker/podman run arguments needed for the container. userns=keep-id is required to get the container working for rootless users (to give them access to the files they are working on, which reside on the host with their local UID/GID).

At the same time, I don't control how users have set up their podman; they might be using it in rootful or rootless mode. (Many are tricked into the rootful mode by the Windows installation instructions, which effectively state: use rootful if you run into some issues. And since there seems to be no down-side, they just go with the "safe route".)

That's where I'm stuck: I want to get a command-line that works for both rootful and rootless invocations, but with "--userns=keep-id" erroring out, I can't find the magic invocation that works in any case.

Suggest potential solution

If "--userns=keep-id" or PODMAN_USERNS is specified in rootful mode, ignore it (and warn about it), but do not error out.

Have you considered any alternatives?

The alternatives require assembling a command-line or an environment variable conditionally depending on podman being rootful or rootless mode, which typically requires a wrapper script.

Or (and that's what we do today) we have to document that the user needs to add a flag or a configuration file depending on how they're using podman.

Additional context

Add any other context or screenshots about the feature request here.

@imphil imphil added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 2, 2023
@giuseppe
Copy link
Member

giuseppe commented Feb 3, 2023

I think we cannot just ignore the setting. When you pass userns the expectation is to create a user namespace.

What could possibly be done, is to create a user namespace and map the same range as the host.

@giuseppe
Copy link
Member

giuseppe commented Feb 3, 2023

opened a PR: #17350

giuseppe added a commit to giuseppe/libpod that referenced this issue Feb 3, 2023
copy the current mapping into a new user namespace, and run into a
separate user namespace.

Closes: containers#17337

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@imphil
Copy link
Contributor Author

imphil commented Feb 3, 2023

Wow, that was quick! Thanks a lot, I'll give it a try on Monday.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants