This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add default non-root user to all dev containers #108
Comments
Correction - We will need to support a "buildArg" property to make this work since the USER_UID portion of the above won't work as a docker run argument. Text corrected above. |
This was referenced Jul 30, 2019
/cc: @brettcannon @testforstephen - I updated the Java and Python dev container definitions to include a non-root user with a UID/GID of 1000 when one was not already in the base image. |
Closing in favor of microsoft/vscode-remote-release#1155. Dev containers in this repo now all have a default user and sudo installed by default. In addition all of the vscode-remote-try-* repos are using this non-root user by default. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
While on mac and Windows, developers can run as root inside the container without trouble, on Linux, local bind mounts use the same permissions as the user inside the container. Since the docker daemon is typically running as root, this means all files that are created or modified are root.
To avoid this problem, you typically create a user with the same UID/GID in the container and pass in
-u user-name-here
todocker run
or adduser
indocker-compose.yml
.If you are running Linux locally, the default user typically has a UID of 1000, so images like
node
provide a user in the container with this UID. Unfortunately, this is the exception rather than the rule.To work around this issue, each dev container Dockerfile should provide a default non-root user with a argument based UID/GID and add comments into devcontainer.json and/or docker-compose.yml on how to use it.
For example:
devcontainer.json, then would have the following in it:
However, if your user has an UID other than 1000, you end up needing to update the Dockerfile.
If we supported a "buildArgs" property (microsoft/vscode-remote-release#46), this could be:
Unfortunately,
${env:UID}
does not pick up $UID. If we introduce microsoft/vscode-remote-release#1050 we could then improve this to be completely automatic:The text was updated successfully, but these errors were encountered: