Vscode-remote-release: Attaching to a container with non root user

Created on 7 May 2019  路  4Comments  路  Source: microsoft/vscode-remote-release

Version: 1.34.0-insider
Commit: 473af338e1bd9ad4d9853933da1cd9d5d9e07dc9
Date: 2019-05-01T05:15:04.403Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
Local OS: Linux x64 4.18.0-17-generic
Remote OS: Linux x64 4.18.0-17-generic
Remote Extension/Connection Type: Docker

Steps to Reproduce:

  1. Run docker container with non root user
  2. Attach to the running container

Trace
Run: docker exec -w /root/.vscode-remote/bin/473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 -u 0 9b56168d9ee0bddb54902fc446e470659d2a76323f5edbee23b5e5c69f86677e /bin/sh -c command -v git >/dev/null 2>&1 && git config --system credential.helper '!f() { command -v code-insiders >/dev/null 2>&1 && code-insiders --gitCredential $; }; f' || true
OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "chdir to cwd (\"/root/.vscode-remote/bin/473af338e1bd9ad4d9853933da1cd9d5d9e07dc9\") set in config.json failed: permission denied": unknown
Command failed: docker exec -w /root/.vscode-remote/bin/473af338e1bd9ad4d9853933da1cd9d5d9e07dc9 -u 0 9b56168d9ee0bddb54902fc446e470659d2a76323f5edbee23b5e5c69f86677e /bin/sh -c command -v git >/dev/null 2>&1 && git config --system credential.helper '!f() { command -v code-insiders >/dev/null 2>&1 && code-insiders --gitCredential $
; }; f' || true

Error
Error is due to use of git config --system. Without --system works ok

Does this issue occur when you try this locally?: No
Does this issue occur when you try this locally and all extensions are disabled?: Didn't check

containers needs-more-info

Most helpful comment

Try adding ENV HOME /home/node after USER node. Does that fix it?

All 4 comments

It's using -u 0, so it should run as root. The error is about changing the current working directory.

Could you share the container image or Dockerfile? (Maybe a simplified one if it is large and/or private.)

Sure:
Dockerfile

FROM node:10.15.3-stretch

RUN echo 'Acquire::http::Proxy "http://apt-cacher-ng:3142";' >> //etc/apt/apt.conf \
    && apt-get update
RUN apt-get install -y vim

USER node
WORKDIR /home/node

RUN echo "\
proxy=http://npm-proxy-cache:8080\n\
https-proxy=http://npm-proxy-cache:8080\n\
strict-ssl=false\
" > /home/node/.npmrc

Docker run:

#!/bin/bash

docker run --rm -it --network=mynetwork -v $(pwd):/home/node/work kitchen-client bash

Try adding ENV HOME /home/node after USER node. Does that fix it?

Great - this worked. Thanks vm!

Was this page helpful?
0 / 5 - 0 ratings