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

Dev Container 0.255.2 : Default remote user as change from root to node #7307

Closed
ijaouani opened this issue Oct 7, 2022 · 13 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded
Milestone

Comments

@ijaouani
Copy link

ijaouani commented Oct 7, 2022

  • VSCode Version: 1.72.0
  • Local OS Version: Windows 11 Pro 22H2
  • Remote OS Version: N/A
  • Remote Extension/Connection Type: Containers stable v0.255.2 or prerelease 0.256.0

Steps to Reproduce:

  1. Create a new devcontainer using for exemple nodejs template and reopen in container.

image

  1. In devcontainer.json comment the line 31 :
30	// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
31	// "remoteUser": "node"
  1. After rebuild the user is still node not root :

image

This is working correctly when rolling back to previous stable version 0.251.0.

@github-actions github-actions bot added the containers Issue in vscode-remote containers label Oct 7, 2022
@simensol
Copy link

simensol commented Oct 8, 2022

I think this is the reason I suddenly started to get errors when trying to execute npm install from within the devcontainer:

[2022-10-08T06:09:47.742Z] npm 
[2022-10-08T06:09:47.748Z] ERR! code EACCES
[2022-10-08T06:09:47.751Z] npm
[2022-10-08T06:09:47.752Z]  
[2022-10-08T06:09:47.754Z] ERR! 
[2022-10-08T06:09:47.754Z] syscall
[2022-10-08T06:09:47.755Z]  mkdir
[2022-10-08T06:09:47.756Z] npm 
[2022-10-08T06:09:47.756Z] ERR! 
[2022-10-08T06:09:47.757Z] path
[2022-10-08T06:09:47.758Z]  /workspaces/frontend/node_modules/@babel
[2022-10-08T06:09:47.761Z] npm ERR! errno -13
[2022-10-08T06:09:47.770Z] npm ERR! Error: EACCES: permission denied, mkdir '/workspaces/frontend/node_modules/@babel'
npm ERR!  [Error: EACCES: permission denied, mkdir '/workspaces/frontend/node_modules/@babel'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!
[2022-10-08T06:09:47.774Z]    syscall: 'mkdir',
[2022-10-08T06:09:47.775Z] npm ERR!
[2022-10-08T06:09:47.775Z]    path: '/workspaces/frontend/node_modules/@babel'
[2022-10-08T06:09:47.775Z] npm ERR!
[2022-10-08T06:09:47.776Z] 
[2022-10-08T06:09:47.777Z]  }
[2022-10-08T06:09:47.779Z] npm
[2022-10-08T06:09:47.780Z]  
[2022-10-08T06:09:47.781Z] ERR!
[2022-10-08T06:09:47.782Z]  
[2022-10-08T06:09:47.783Z] 
[2022-10-08T06:09:47.784Z] npm 
[2022-10-08T06:09:47.788Z] ERR!
[2022-10-08T06:09:47.790Z] 
[2022-10-08T06:09:47.790Z]  The operation was rejected by your operating system.
[2022-10-08T06:09:47.791Z] npm ERR!
[2022-10-08T06:09:47.791Z]  It is likely you do not have the permissions to access this file as the current user
[2022-10-08T06:09:47.791Z] 
[2022-10-08T06:09:47.792Z] npm 
[2022-10-08T06:09:47.793Z] ERR! 
npm 
[2022-10-08T06:09:47.794Z] ERR!
[2022-10-08T06:09:47.795Z]  If you believe this might be a permissions issue, please double-check the
[2022-10-08T06:09:47.802Z] npm 
[2022-10-08T06:09:47.803Z] ERR!
[2022-10-08T06:09:47.804Z]  permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
[2022-10-08T06:09:47.809Z] 
[2022-10-08T06:09:47.809Z] npm ERR!
[2022-10-08T06:09:47.810Z]  A complete log of this run can be found in:
npm
[2022-10-08T06:09:47.811Z]  ERR!

Rolling back to 0.251.0 fixed the issue.

@chrmarti
Copy link
Contributor

The remoteUser is now included in the base image. If you need it to be root, you can specify "remoteUser": "root" in the devcontainer.json.

/cc @bamurtaugh @Chuxel

@chrmarti chrmarti self-assigned this Oct 10, 2022
@simensol
Copy link

"remoteUser": "root" fixed my npm install issue above for both the python and javascript-node base images. I had to rebuild the containers without cache to get rid of some other permission errors, though. Maybe mention this explicitly in the docs?

@ijaouani
Copy link
Author

The remoteUser is now included in the base image. If you need it to be root, you can specify "remoteUser": "root" in the devcontainer.json.

/cc @bamurtaugh @Chuxel

It's that I did but I think the containers definitions need to be updated to avoid confusion.

@simensol
Copy link

With "remoteUser": "root", when I attach to a running devcontainer (or do Developer: Reload Window from within the devcontainer) the user is no longer root, but a user named vscode in the devcontainer based on the python base image, and a user named node in the devcontainer based on the javascript-node base image. To get back as root user, I have to rebuild the devcontainer(s).

The problem is that I'm connecting to multiple containers using one docker-compose.yml for both the python and javascript-node devcontainers. If I start the python devcontainer and then try to attach to the javascript-node devcontainer, the user is now node and not root. However, if I rebuild the javascript-node devcontainer to get back as root, the connection to the python devcontainer is lost.

It's the same the other way around: If I start the javascript-node devcontainer and then try to attach to the python devcontainer, the user is now vscode and not root. If I rebuild the python devcontainer to get back as root, the connection to the javascript-node devcontainer is lost.

In other words, it is not possible to get into both devcontainers as root at the same time.

@chrmarti
Copy link
Contributor

@simensol Not sure I fully understand what is going on, but could you try using "shutdownAction": "none" in the devcontainer.json files involved? That should prevent the rebuild from affecting the other container.

@simensol
Copy link

I already have "shutdownAction": "none" in both devcontainer.json files. However, this (rebuilds affecting the other container) has also been an issue in previous versions, but I have always been able to get back by reloading the window or attaching to an existing devcontainer. Now, that I "loose" the root user, this workaround doesn't work anymore.

Rolling back to 0.251.0 fixes the issue where the "remoteUser": "root" is not respected when attaching to a running devcontainer (or when I do Developer: Reload Window from within the devcontainer). Updating again to 0.255.2 results in the root user being available only the first time the devcontainer is created (as described above).

@mhofman
Copy link

mhofman commented Oct 10, 2022

I have a similar but somewhat mirror issue. I have a container I branched off the node-typescript image some time ago. The remote extension just updated and now whatever the setting of remoteUser, the container keeps starting as root instead of the node user. Any suggestion besides rebuilding the container based on a newer image?

chrmarti added a commit to devcontainers/cli that referenced this issue Oct 11, 2022
chrmarti added a commit to devcontainers/cli that referenced this issue Oct 11, 2022
@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Oct 11, 2022
@chrmarti chrmarti added this to the October 2022 milestone Oct 11, 2022
@chrmarti
Copy link
Contributor

Added a fix in Dev Containers 0.259.0-pre-release. Could you give that a try and let me know if that fixes it? Thanks.

@mhofman
Copy link

mhofman commented Oct 11, 2022

At the very least for my case, 259 does fix the issue, and a simple "remoteUser": "node" works again.

@simensol
Copy link

0.259.0-pre-release seems to have fixed my issues as well. Reloading any of the two devcontainers now resumes with root as user every time.

@chrmarti
Copy link
Contributor

Fix is now also available in Dev Containers 0.255.3.

@rzhao271 rzhao271 added the verified Verification succeeded label Oct 26, 2022
@jhzsquared
Copy link

I'm having a similar issue where "ShutdownAction": "none" is being ignored in my devcontainer.json file-- my container is restarting everytime I exit vscode/the specific devcontainer window. I've tried the various versions of the devcontainer extension: to include 0.255.3 , 0.259.0 and the newest (0.262.3) with no luck. Not sure why it's not working.

I'm on VSCode version 1.73.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants