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

Podman Usage Improvements #6759

Open
nlvw opened this issue May 25, 2022 · 4 comments
Open

Podman Usage Improvements #6759

nlvw opened this issue May 25, 2022 · 4 comments
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality podman Dev Container using Podman
Milestone

Comments

@nlvw
Copy link

nlvw commented May 25, 2022

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

@Chuxel Chuxel transferred this issue from microsoft/vscode-dev-containers May 25, 2022
@tanhakabir tanhakabir added the containers Issue in vscode-remote containers label May 27, 2022
@chrmarti chrmarti self-assigned this Jun 1, 2022
@chrmarti chrmarti added the feature-request Request for new features or functionality label Jun 1, 2022
@chrmarti chrmarti added this to the Backlog milestone Jun 1, 2022
@rhatdan
Copy link

rhatdan commented Jul 9, 2022

Any movement on this issue?

@fulldecent
Copy link

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.

@nlvw
Copy link
Author

nlvw commented Dec 7, 2022

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.

@chrmarti chrmarti added the podman Dev Container using Podman label Dec 12, 2023
@bam80
Copy link

bam80 commented Jan 25, 2024

Progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality podman Dev Container using Podman
Projects
None yet
Development

No branches or pull requests

6 participants