Configuring containerUser and remoteUser in Gitspace
This guide explains how to set up containerUser
and remoteUser
in your Gitspace using the properties in the devcontainer.json
schema.
What are "containerUser" and "remoteUser"?
These properties control the permissions of applications executed within containers, giving developers fine-grained control over container operations. (Read more about the specification here.)
containerUser
- The user with which the development container is started.
- It handles all processes and operations inside the container.
- This concept is native to containers.
- The default user is either the user specified in the Docker image or the root user.
remoteUser
- The username used for running processes inside the container, including lifecycle scripts and any remote editor/IDE server processes.
- This concept is not native to containers.
- The default user is the same as the containerUser.
How to define a containerUser?
You can define a containerUser in the following ways:
- Using the containerUser Property in
devcontainer.json
:
"containerUser": "root"
- Using the user Argument in the runArgs Property in
devcontainer.json
:
"runArgs": ["--user=root"]
- Defining user during the Image Build (Image Metadata).
Priority Order:
If multiple definitions exist, the containerUser is set based on the following priority:
runArgs
definitiondevcontainer.json
specification- Image Build
How to define a remoteUser?
You can define a remoteUser in the following ways:
- Using the remoteUser Property in
devcontainer.json
:
"remoteUser": "vscode"
- Defining remoteUser in Image Metadata.
Priority Order:
If multiple definitions exist, the remoteUser is set based on the following priority:
devcontainer.json
specification- Image metadata
Static Password: A static password is maintained for the remoteUser in case the user gets locked: Harness@123.
We assume that the user has a valid home directory. For the root user: /root and For non-root users: /home/username
Verifying the Setup
After adding this property, you can verify the setup by reviewing the container logs during the creation of a Gitspace via the Harness UI.