Skip to content

Commit 923bce4

Browse files
committed
add docs for ContainerUser
1 parent 49f0358 commit 923bce4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/ContainerCustomization.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,27 @@ ContainerEntrypointArg items have one property:
207207
</ItemGroup>
208208
```
209209

210+
## ContainerUser
211+
212+
This item controls the default user that the container will run as. This is often used to run the container as a non-root user, which is a best practice for security. There are a few constraints to know about this field:
213+
214+
* It can take a variety of forms - user name, linux user ids, group name, linux group id, `username:groupname`, id variants of the above
215+
* There is no verification that the user or group specified exists on the image
216+
* Changing the user can alter the behavior of the application, especially in regards to things like File System permissions
217+
218+
The default value of this field varies by project TFM and target operating system:
219+
220+
* if you are targeting .NET 8 or higher and using the Microsoft runtime images, then
221+
* on Linux the rootless user `app` will be used (though it will be referenced by its user id)
222+
* on Windows the rootless user `ContainerUser` will be used
223+
* otherwise no default `ContainerUser` will be used
224+
225+
```xml
226+
<PropertyGroup>
227+
<ContainerUser>my-existing-app-user</ContainerUser>
228+
</PropertyGroup>
229+
```
230+
210231
## Default container labels
211232

212233
Labels are often used to provide consistent metadata on container images. This package provides some default labels to encourage better maintainability of the generated images, drawn from the set defined as part of the [OCI Image specification](https://github.com/opencontainers/image-spec/blob/main/annotations.md). Where possible, we use the values of common [NuGet Project Properties](https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target) as defaults for these annotations, though we also provide more specific properties for each of these labels.

0 commit comments

Comments
 (0)