Search code examples
dockervisual-studio-codevscode-devcontainer

VS Code devcontainer - what is the difference between containerUser and USER in Dockerfile?


From the doc

containerUser: Overrides the user for all operations run as inside the container. Defaults to either root or the last USER instruction in the related Dockerfile used to create the image.

Does it mean that when you set up containerUser below in devcontainer.json

"containerUser": "user-name"

Just same as USER in Dockerfile as below??

USER user-name

Solution

  • From the definition of devcontainer.json schema

    {
      "containerUser": {
        "type": "string",
        "description": "The user the container will be started with. The default is the user on the Docker image."
      },
    }
    

    So, containerUser is the same as the User on the Docker Image.