Repository navigation
Closed
Labels
Milestone
Description
@chrmarti I have done some investigations and on Windows WSL and macOS things work out of the box: no need for `z` and `--userns` options.
On Linux things are a little bit more complicated but we may solve the problem if the Dev Containers extension:
- sets the environment variable
PODMAN_USERNS=keep-idbefore runningpodman/docker runcommands - adds
--security-opt label=disablefor everypodman/docker runcommand
With these two changes, setting the z and --userns options wouldn't be needed anymore. It works for both rootless and rootful Podman.
Here is a detailed explanation:
- For rootful podman, the option to relabel the file objects (
zorZ) may (*) be required (--security-opt label=disableworks too) - For rootless podman, in addition to the relabelling, the option to keep the same user id in the namespace (
--userns=keep-id) is required. - Docker (rootful) has
--security-opt label=disableand as a consequence doesn't need any specific flag/option.
(*) it may work without that option depending on the existing labels and permissions of the folder that we want to bind mount, but to always work, z is required.
To set the relabel option there are multiple options (the bold one may be more adapted for Dev Containers):
- use the
:zor:Zvolume option - add the
--security-opt label=disabletopodman runcommand - set
label = falsein[containers]section ofcontainers.conf
To set userns to keep-id there are multiple options too (the bold one may be more adapted for Dev Containers):
- add the
--userns=keep-idtopodman runcommands (but that doesn't seem like a valid value for Docker) export PODMAN_USERNS=keep-id- set
userns = "keep-id"in[containers]section ofcontainers.conf
Originally posted by Mario Loriedo (@l0rd) in microsoft/vscode-docs#8122 (comment)
Reacted by Philipp Wagner
Activity
chrmarti commentedon Apr 4, 2025
Thanks for investigating Mario Loriedo (@l0rd)! We can use the command line options since we already know if we are using podman: devcontainers/cli#985.
chrmarti commentedon Apr 24, 2025
Fixed in Dev Containers extension 0.412.0-pre-release and Dev Containers CLI 0.76.0.
daphnediane commentedon May 14, 2025
I've been seeing issues related to --userns=keep-id breaking devcontainers that use
--uidmapand--gidmapwhich is incompatible with the--usernsoptions.Looks like adding
"--userns="torunArgsfixes the issue.l0rd commentedon May 14, 2025
Daphne Pfister (@daphnediane), thank you for sharing this. Christof Marti (@chrmarti), we may avoid such problems by using the environment variable
PODMAN_USERNS=keep-id(rather than adding--userns=keep-id). Flags have higher priority than environment variables, and compatibility issues wouldn't exist.