Skip to content

Podman on Linux improvements #10798

Closed
Closed

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-id before running podman/docker run commands
  • adds --security-opt label=disable for every podman/docker run command

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 (z or Z) may (*) be required (--security-opt label=disable works 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=disable and 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 :z or :Z volume option
  • add the --security-opt label=disable to podman run command
  • set label = false in [containers] section of containers.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-id to podman run commands (but that doesn't seem like a valid value for Docker)
  • export PODMAN_USERNS=keep-id
  • set userns = "keep-id" in [containers] section of containers.conf

Originally posted by Mario Loriedo (@l0rd) in microsoft/vscode-docs#8122 (comment)

Activity

  1. added
    containers
    debt
    on Mar 19, 2025
  2. added
    podman
    on Apr 4, 2025
  3. chrmarti commented on Apr 4, 2025

    @chrmarti
    ContributorAuthor

    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.

  4. chrmarti commented on Apr 24, 2025

    @chrmarti
    ContributorAuthor

    Fixed in Dev Containers extension 0.412.0-pre-release and Dev Containers CLI 0.76.0.

  5. daphnediane commented on May 14, 2025

    @daphnediane

    I've been seeing issues related to --userns=keep-id breaking devcontainers that use --uidmap and --gidmap which is incompatible with the --userns options.

    Error: cannot specify custom mappings with --userns=keep-id
    

    Looks like adding "--userns=" to runArgs fixes the issue.

  6. l0rd commented on May 14, 2025

    @l0rd

    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.

  7. locked and limited conversation to collaborators on Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

containersdebtpodman

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions