Repository navigation
Closed
Description
- VSCode Version: 1.34.0-insider
- Local OS Version: macOS Mojave
- Remote OS Version: Debian Stretch
- Remote Extension/Connection Type: Docker
Steps to Reproduce:
- Create
Dockerfilewith user different than root
RUN usermod -u 1020 application
USER application
- Run container
- Run
Remote Containers: Attach to running container... - Select container you want to attach to
- Setup process fails with the following error:
Setting up container with 575f427ee0eab56f3e140dda2aabd89fd80a2e7ab48795e0532d728e73694333
Run: docker exec 575f427ee0eab56f3e140dda2aabd89fd80a2e7ab48795e0532d728e73694333 /bin/sh -c (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Run: docker exec 575f427ee0eab56f3e140dda2aabd89fd80a2e7ab48795e0532d728e73694333 test -d /root/.vscode-remote/bin/473af338e1bd9ad4d9853933da1cd9d5d9e07dc9
Installing VS Code Server for commit 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9
Run: docker exec 575f427ee0eab56f3e140dda2aabd89fd80a2e7ab48795e0532d728e73694333 mkdir -p /root/.vscode-remote/bin/473af338e1bd9ad4d9853933da1cd9d5d9e07dc9_1556829785420
mkdir: cannot create directory ‘/root’: Permission denied
Command failed: docker exec 575f427ee0eab56f3e140dda2aabd89fd80a2e7ab48795e0532d728e73694333 mkdir -p /root/.vscode-remote/bin/473af338e1bd9ad4d9853933da1cd9d5d9e07dc9_1556829785420
That's because the user specified in Dockerfile can't create directories in /root. Is there a way for vscode to select different path than /root/.vscode-remote?
Reacted by Prasanth, Aksarin Mikhail, nickolai-voyage, smhc and Chris Kay
Activity
Chuxel commentedon May 2, 2019
Damian Pukaluk (@threaz) It will respect whatever HOME is set to, so this will work:
Does this solve your issue?
javierdihu commentedon May 2, 2019
I'm having the exact same issue but I don't have access to modify the Dockerfile of the container image, which doesn't specify a HOME. Is there any other way around this? Thanks.
[-]Permission denied during attaching[/-][+]Add option to override install directory[/+]threaz commentedon May 3, 2019
Thanks for your response Chuck Lantz (@Chuxel). Specifying
ENV HOME /home/$USERNAMEhas helped indeed. I was kind of confused, because$HOMEwas already set to correct value, but it seems code expects explicit statement inDockerfile.[-]Add option to override install directory[/-][+]Determine install folder from within the container[/+]chrmarti commentedon May 3, 2019
Ideally we would find out what the home folder is from within the container without relying on HOME on the container's or image's inspect data. For now setting HOME with
ENVin the Dockerfile is the correct workaround. (Changed title to reflect this.)vijay609 commentedon May 17, 2019
I am having the same issue. I don't have access to the DockerFile.
Here's a dirty workaround that worked for me:
sudo service docker stopHOME=/home/vijay609to theENVsection.sudo service docker startcostela commentedon May 17, 2019
Javier Diaz (@javierdihu) and vijay609: if you don't have access to the
Dockerfile, you can still work around this. If you're working on a "bare" docker setup, you can use something like the following in yourdevcontainer.json:{ ... "runArgs": [ "--env", "HOME=/home/yourusername" ] }If you're using
docker-compose, than you'd need something like:{ "dockerComposeFile": [ "path/to/your/base/docker-compose.yml", "docker-compose.extend.yml" ], "service": "yourservice", ... }and inside
.devcontainer/docker-compose.extend.yml:disclaimer: I only tested the
docker-composeapproach, but the bare docker one should work just as well.nickolai-voyage commentedon May 17, 2019
vijay609 Thanks for the tip. Note that this doesn't work if the container was started with
--rmas it will be deleted upon stopping the docker service.nickolai-voyage commentedon May 20, 2019
Christof Marti (@chrmarti) Why not install in /tmp? Out of curiosity, what are you installing inside the image anyway?
costela commentedon May 21, 2019
nickolai-voyage educated guess: because
/tmpis frequently mounted astmpfswithnoexec. Attempting to find a$HOMEseems less error-prone (from my admittedly uninformed perspective).chrmarti commentedon May 21, 2019
nickolai-voyage We install the VS Code Server. Using the user's home folder seemed to make the most sense since that is also owned by the same user (which is not necessarily root), we also place settings and extensions in
~/.vscode-remote.patrick-mota commentedon May 22, 2019
Seems a good idea Christof Marti (@chrmarti) and doing what Leo Antunes (@costela) said resolved the problem.
I just added
HOME: /home/yourusername
in environnment for the service where vscode remote will enter.
SoftwareApe commentedon Jun 7, 2019
Running the container with
docker run -e HOME=/user/yourusernamealso works. It would be nice if there was a helpful warning message, even better additionally a configuration option "remote-containers.home".chrmarti commentedon Jun 7, 2019
We now read the home folder from
/etc/passwd. (Available in 0.60.0, which currently requires VS Code Insiders to install.)MojoJojo86 commentedon Jun 15, 2019
Carl Mueller-Roemer (@SoftwareApe) Would this potentially be possible with something like docker-compose up -e HOME=/user/yourusername?
I've tried adding the mentioned solutions to my dockerfile or docker-compose.yml but still get the no access to root message. :(
chrmarti commentedon Jun 17, 2019
Joseph Bradshaw (@MojoJojo86) Would using the home folder from
/etc/passwdhelp? If so, could you give the VS Code Insiders build a try? That gets a newer version of the Remote Containers extension.SoftwareApe commentedon Jun 17, 2019
Joseph Bradshaw (@MojoJojo86) thank you, the home folder trick works on stable!
MojoJojo86 commentedon Jun 17, 2019
Christof Marti (@chrmarti) Cheers I tried the insiders edition and that worked.