vscode-dev-containers icon indicating copy to clipboard operation
vscode-dev-containers copied to clipboard

UID in client is only adapted if switched to non-root via name but not if switched via UID in dockerfile.

Open user1584 opened this issue 2 years ago • 0 comments

  • VSCode Version: 1.74.3
  • Local OS Version: Ubuntu 20.04
  • Local chip architecture: x86
  • Reproduces in: Remote - Containers
  • Name of Dev Container Definition with Issue:

Steps to Reproduce:

  1. In the client, create a non-root user and switch to non-root user via UID instead of the user name
FROM ubuntu AS test

ARG NON_ROOT_USER=non_root_user
ARG NON_ROOT_UID=1000
ARG NON_ROOT_GID=100

USER root

# Create non-root user
RUN useradd \
    --no-log-init \
    --no-user-group \
    --shell /bin/bash \
    --create-home \
    --uid ${NON_ROOT_UID} \
    --gid ${NON_ROOT_GID} \
    ${NON_ROOT_USER}

# This works:
# USER ${NON_ROOT_USER} 

 # This does not work:
USER ${NON_ROOT_UID}
  1. Start devcontainer with
{
  "build": {
    "dockerfile": "Dockerfile",
    "target": "test"
  },
  "runArgs": [
    "--rm"
  ]
}
  1. Check the UID of the User within the devcontainer via id. If switching to the non-root user via USER ${NON_ROOT_USER}, you should get the UID of the user from the host. If switching via USER ${NON_ROOT_UID}, the UID will remain at 1000.

user1584 avatar Mar 27 '23 19:03 user1584