mcp: run image as numeric non-root user#94
Open
SarthakB11 wants to merge 1 commit into
Open
Conversation
The mcp image created a non-root user but never set USER, so the container still ran as root. Set USER to the numeric UID 14000 and align the user with the root image's doc2vec:14000 account. A numeric USER lets kubelet enforce runAsNonRoot and lets downstream charts (such as kagent's querydoc subchart) drop their runAsUser pin. Signed-off-by: Sarthak Bhardwaj <sarthak.bhardwaj21b@iiitg.ac.in>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
mcp/Dockerfilecreates a non-root user but never setsUSER, so the container runs as root. This setsUSERto the numeric UID14000and aligns the runtime user with the root image'sdoc2vec:14000account.Why
With no
USER, the image runs as root, which forces consumers to pinrunAsUserin their pod spec and blocks rootless or OpenShift-style deployments. A numericUSERlets kubelet verifyrunAsNonRootat admission time (a non-numeric username cannot be checked). It also lets downstream charts, such as kagent'squerydocsubchart that pulls this image, drop theirrunAsUserpin.How verified
Built with buildx and ran the image:
docker run --entrypoint idreportsuid=14000(doc2vec) gid=14000(doc2vec)docker inspect -f '{{.Config.User}}'reports14000/appand/app/buildare owned bydoc2vec, and the runtime user can write to/app/build(needed for SQLite journal/WAL files)