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

Improving Podman users experience: avoid setting $HOME #10707

Open
l0rd opened this issue Feb 14, 2025 · 2 comments
Open

Improving Podman users experience: avoid setting $HOME #10707

l0rd opened this issue Feb 14, 2025 · 2 comments
Assignees
Labels
containers Issue in vscode-remote containers debt podman Dev Container using Podman
Milestone

Comments

@l0rd
Copy link

l0rd commented Feb 14, 2025

Hi 👋, I am Mario, and I am a Podman maintainer.

Kudos to the team for the Dev Containers extension 🚀. It's a great project, and we look forward to collaborating to improve Podman users' UX.

For this reason, I am trying to find a solution to avoid having to explicitly set $HOME in a .vscode/devcontainer.json to successfully start a Dev Container with Podman (this workaround is mentioned in the documentation).

Currently, if a user doesn't set $HOME in the devcontainer.json, the container startup fails because the extension tries to create a folder in /root instead of $HOME:

mkdir: cannot create directory '/root': Permission denied

Steps to Reproduce:

  1. Configure Dev Containers extension to use podman as described in doc
  2. Locally clone the repository https://github.com/microsoft/vscode-remote-try-go and open it in VS Code
  3. Open the command palette and select Dev Containers: Open Folder in Container

Analyzing the failure

This is what I could infer from the Dev Containers log and may not be 100% accurate but those are the steps that preceded the error:

  1. The container is started and, as a user is not specified, the default (root) is used
  2. The extension inspects the container and reads the Config.Env["HOME"] to infer $HOME:
    • when it's Podman HOME=/root
    • when it's Docker HOME is not set
  3. The extension runs a podman/docker exec command, as user vscode, to create the folder $HOME/.vscode-server/bin`
    • when it's Podman the flag --env=HOME=/root is passed to the exec command
    • when it's Docker the flag --env=HOME=/home/vscode is passed to the exec command

Podman sets HOME=/root when starting the container. But this is intended: when $HOME is unset, Podman sets it based on/etc/passwd. This is a valuable feature as many command line tools expect $HOME to be set.

Proposals to address the problem

Avoid inspecting the $HOME environment variable, of a container started as an arbitrary user (often this means root), to infer the $HOME variable to use with user vscode.


  • VSCode Version: 1.96.4
  • Local OS Version: macOS 15.3
  • Remote OS Version: Fedora 41
  • Remote Extension/Connection Type: Dev Containers
@vs-code-engineering vs-code-engineering bot added the containers Issue in vscode-remote containers label Feb 14, 2025
@chrmarti
Copy link
Contributor

Hi Mario, thanks for investigating! To avoid breaking existing devcontainers we could check if the user has write access on $HOME and ignore the variable if not.

@chrmarti chrmarti added this to the March 2025 milestone Feb 19, 2025
@chrmarti chrmarti added debt podman Dev Container using Podman labels Feb 19, 2025
@l0rd
Copy link
Author

l0rd commented Feb 19, 2025

@chrmarti thank you for looking at this 🙌. Sure, this should be fine too!

Another option would be to figure out if you are talking with Podman (using the ping API for example) and avoid inferring $HOME by inspecting when it's the case. It may be overkill for this particular issue, but it would help in the future if you want to provide better Podman support.

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 debt podman Dev Container using Podman
Projects
None yet
Development

No branches or pull requests

2 participants