Skip to content

New app user for .NET 8 images isn't documented as a potentially breaking change #4451

@rwkarg

Description

@rwkarg

Describe the Bug

The new app user for .NET 8 images (#4397) is an undocumented breaking change for users that are currently creating a user named app on top of .NET 7 and earlier images.

Documented breaking changes

Steps to Reproduce

Have a Dockerfile that builds off of one of the Microsoft images (ex. dotnet/aspnet) in use with .NET 7 or earlier tags

ARG TAG_VERSION
FROM mcr.microsoft.com/dotnet/aspnet:${TAG_VERSION}

# Minimal steps to produce error
RUN groupadd -r app && \
    useradd -m -u 10005 -r -g app -d /home/app -s /sbin/nologin -c "Docker image user" app
USER app

Now Set TAG_VERSION to a .NET 8 tag (ex. 8.0.0-preview.1) and docker build

--> Container image build error since app user already exists.

Other Information

Preferred Outcome: Use a higher number user id (>10,000) and document how this addition may break existing workflows when upgrading to .NET 8 where an app user is currently being created on top of .NET 7 or earlier tags.

We currently build images off the base Microsoft images to add a non-root user (as well as other unrelated specializations not relevant to this issue) and just happen to currently use app as the user name.

We could address this by omitting the RUN step to add a user and use the provided app user, but that still runs in to an issue with our deployments to Kubernetes. The securityContext for the pods/containers specify a runAsUser that requires the user id.

The .NET 8 images create the user with id 101 which will not work for our existing deployments. This would require coordinating our .NET 8 upgrades, per service, with similar updates to our deployments to align the ids.

Additionally, recommendations are to use a high numbered user id (>10,000 is a recommendation I've seen in several places, including the security scanning tool Trivy regarding this specific vulnerability)

Blog post regarding container user colliding with a host user having the same id: Understanding how uid and gid work in Docker containers

The other way we could address this is to remove the new app user and then continue with creating our own app as before, but this is also a breaking change to our container build process that we need to address to upgrade.

Metadata

Metadata

Assignees

Labels

area-dockerfilesConcerns the official .NET Dockerfiles or Dockerfile templates

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions