Skip to content

Podman Usage Improvements #6759

Open
Open

Description

Improve default handling of both user Home directories and the use of Podman.

This post is mostly to document Podman specific configuration for devcontainer.json to get it working in a friendly fashion. The feature request part is more of a plea to improve the default support so a lot of this custom config is unnecessary.

  1. Add built-in support for mounting user home directory.
    1.1 Mounting the users home directory is important as it solves the git + ssh issue as your keys and git config will be available inside the container (not everyone uses an ssh agent). It also exposes other user configs such as git configuration, bash configuration, and other tooling. The end result is a better default environment to work out of.
  2. Podman should be run unprivileged and as the current user by default.
  3. When using Podman selinux needs to be detected and handled without needing specific flags in devcontainer.json.
    3.1. 'Z'/'z' should be avoided in bind/volume mounts as it changes the selinux context on files permanently which can break regular access to those files. For instance if you were to mount $HOME/.ssh you would break key based ssh authentication for that user until the context is manually reset.

settings.json

{
        "terminal.integrated.defaultProfile.linux": "bash",
	"remote.containers.dockerPath": "podman",
	"remote.containers.dockerComposePath": "podman-compose"
}

devcontainer.json (podman specific settings)

{
  "workspaceMount": "",
  "workspaceFolder": "${localWorkspaceFolder}",
  "runArgs": [
    // run container as current user
    "--userns=keep-id",
    // disable selinux isolation that breaks bind mounts
    "--security-opt=label=disable",
    // mount user home directory for things like git, ssh, and other configs
    "--volume=${env:HOME}:${env:HOME}",
    // ensure project directory is mounted incase it exists outside the home directory
    "--volume=${localWorkspaceFolder}:${localWorkspaceFolder}",
    // isolate the .vscode-server folder so you don't overwrite settings from remote ssh vscode
    "--volume=${localWorkspaceFolder}/.cache/vscode-server:${env:HOME}/.vscode-server"
  ],
  "containerEnv": {
    // ensure users home directory is the same inside the container as it is outside
    "HOME": "${env:HOME}"
  }
}

Relates to: Remote - Containers

Activity

  1. added
    containers
    on May 27, 2022
  2. added
    feature-request
    on Jun 1, 2022
  3. rhatdan commented on Jul 9, 2022

    @rhatdan

    Any movement on this issue?

  4. fulldecent commented on Nov 24, 2022

    @fulldecent

    Please do not default to mounting home directory in the container. And please caveat every time when talking about this technique.

    SSH keys on the host should stay secure. And a primary use case of containers is doing insecure things with isolation.

  5. nlvw commented on Dec 7, 2022

    @nlvw
    Author

    Even if it isn't the default behavior there's no need to "caveat" the usage. These are develop environments and different levels of isolation are understandable.

  6. added
    podman
    on Dec 12, 2023
  7. bam80 commented on Jan 25, 2024

    @bam80

    Progress?

  8. tnk4on commented on Jan 1, 2026

    @tnk4on

    Update: Podman Support Improvements Implemented

    The Podman-specific improvements requested in this issue have been implemented in devcontainers/cli:

    Key Changes

    devcontainers/cli#985: Add Podman options (merged 2025-04-07)

    When Podman is detected on Linux, the CLI now automatically adds:

    • --security-opt label=disable — Disables SELinux labeling to prevent mount/socket access issues
    • --userns=keep-id — Maps container user to host UID/GID, fixing file permission issues

    Released in: @devcontainers/cli v0.76.0 (2025-04-24)

    Additional Fixes

    Version PR Fix
    v0.77.0 #1005 Fixed --uidmap/--gidmap conflict with --userns
    v0.77.0 #1005 Omit --userns=keep-id when running as root
    v0.80.0 #1045 Improved SELinux label handling for bind mounts

    Verification

    I've tested with Podman 5.7.1 and @devcontainers/cli 0.80.3. Containers start correctly without requiring manual runArgs configuration for --security-opt or --userns.

    Automated Testing Repository

    I've created a public repository with comprehensive automated compatibility tests to verify these improvements:

    The repository demonstrates that all Podman permission and SELinux issues are resolved. You can view the latest test results, version compatibility matrix, and status badge in the repository README.

    Summary

    The core Podman permission and SELinux issues raised in this thread have been addressed. This issue can be closed.

  9. bam80 commented on Oct 30, 2026

    @bam80

    Compose is still not addressed:
    devcontainers/cli#1300

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

Metadata

Metadata

Labels

containersfeature-requestpodman

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions