Wrong (default ?) user (UID / GID)
What happened?
After cloning a repository and creating a .devcontainer folder itself containing a devcontainer.json file, a Dockerfile and a docker-compose.yml file, the devpod graphical client cannot launch VS Code (this is not the command line case).
Knowing that on my workstation, the account with the UID and GID 1000 are associated with the "suportit" account which is an account installed by the team which manages the PC fleet. My ace account for UID and GID 1001.
My guess is that devpod retrieves the correct "ssh client" when we see the debug line /run/user/1001/keyring/ssh, yet at the level of the "Chown projects..." info log it retrieves id 1000. Which has the side effect of preventing me from modifying the code from my ide launched by the host, because the files belong to 1000 and more than 1001.
What did you expect to happen instead?
Being able to use the graphical version of devops which opens the IDE without errors
How can we reproduce the bug? (as minimally and precisely as possible)
- Create a docker provider with default values
- Clone a repo (with the 3 files inside of the .devcontainer folder, see image above)
- Create a workspace from a local folder (clone on previous step)
My devcontainer.json:
{
"name": "new-sms-server",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceMount": "source=${localWorkspaceFolder}, target=/workspace, type=bind",
"workspaceFolder": "/workdpace"
}
Local Environment:
- DevPod Version: [use
v0.5.22] - Operating System:
Linux(Ubuntu 24.04) - ARCH of the OS:
AMD64
DevPod Provider:
- Local/remote provider: docker | ssh
Anything else we need to know?
@darkterra thanks for reporting your issue! Did you perform a ls -la on the directory to ensure it was owned by UID 1000 and not root? Looking at the code we chown the directory so the remote user on the devcontainer can modify the files. This should be set in the devcontainer.json or as a label on the pod devpod.user. Is this label set on your pod? You can use docker inspect to see this. Also can you try use the remoteUser attribute in devcontainer.json and set this to your user with UID 1001?
Hello @bkneis. Thanks for the response :)
Initially the repo was cloned with the git clone command and the files are therefore the property of my account 1001 (so not 1000 and not root). Because my account has the UID 1001 and not 1000
Then I use devops to create a workspace from a local directory.
When I inspect the container I get the following value at the "Labes" =>
"Label": {
...
"dev.containers.id": "new-sms-se-46f87",
"dev.containers.release": "v0.4.5",
"dev.containers.source": "https://github.com/devcontainer/images",
"devpod.user": "root",
"version": "1.1.5"
}
The thing is that it cannot be used in an "industrial" way, because not everyone in my company has the same ID (1001 in my case). This must respect the current user as is the case for the debug log: "Forwarding ssh-agent using /run/user/1001/keyring/ssh"
In addition to what I understand "remoteUser" asks to enter the username and not the "UID", so really specific to each user.
Hi, is there any workaround for this? I also have an account with id 1001 and building the dev container changes ownership of all files to UID 1000, which does not correspond to any user.
This is a complete blocker to using devpod :/ vscode works fine.
I have the same issue. My workspace uses uid 1000 and gid 1000 for a user/group unrelated to me (let's call these otheruser/othergroup).
The UID/GID for my own user account (let's say myuser:mygroup) are therefore not 1000.#
When I use devpod to create the container in Linux, the workspace ownership is changed to 1000/1000 so it is suddenly owned by otheruser/othergroup instead of myuser/mygroup.
This problem is on Linux with Docker provider.
Simple container spec to test it (default "Basic Python" from VSCode):
{
"name": "Basic Python",
"build": { "dockerfile": "Dockerfile" },
"remoteUser": "vscode",
"customizations": {
"vscode": {
"extensions": ["ms-python.python"]
}
}
}
and:
FROM library/python:3.11-bookworm
ARG USER=vscode
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update \
&& apt install -y --no-install-recommends sudo \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m -s /usr/bin/bash ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
The above works fine when I create the container from within VSCode itself, but DevPod will mess up the permissions.
@karypid thanks for reporting your issue and providing the example! I am running debian 12 and using your example devcontainer and Dockerfile, when I launch the devcontainer using vscode, the workspace is owned by root, not the remoteUser. Can you provide the output of ls -la in your workspace inside the container?
@darkterra are you using a local directory to up the workspace? If so, then this is the intended behaviour. Since your remote user has UID 1000, in order for the workspace to be usuable devpod needs to chown the directory in the container for your user to have permissions. When using git this is not an issue, since there are no local files. But when using a local directory, the issue cannot be avoided since you are using the directory as a user in another user namespace
at least in my case yes, this is with a local directory.
the issue cannot be avoided
but vscode somehow avoids it :sweat_smile:
@eguiraud-pf what platform are you on? I am on debian 12 and when I use vscode alone to open a devcontainer, all my files are owned by root when using @karypid config. Although this does not cause issues with my local file permissions, this is now not ideal for my development within the container. Docker also will do this if you try run the Dockerfile using --user.