Skip to content

fix(docker): switch to non-root user in container images - #4745

Open
teddiesloco wants to merge 1 commit into
modelcontextprotocol:mainfrom
teddiesloco:fix/dockerfile-non-root-user
Open

fix(docker): switch to non-root user in container images#4745
teddiesloco wants to merge 1 commit into
modelcontextprotocol:mainfrom
teddiesloco:fix/dockerfile-non-root-user

Conversation

@teddiesloco

Copy link
Copy Markdown
Contributor

What does this PR do?

Resolves #4741.

Since #2205, the Python Dockerfiles (fetch, git, time) created an app user with --chown=app:app, but never included a USER app instruction before the ENTRYPOINT. As a result, containers ran as UID 0 (root).

Similarly, the Node images (filesystem, memory, etc.) inherit from node:22-alpine which ships with a non-root node user (UID 1000) that was previously unused.

This PR:

  • Adds useradd check and USER app to Python Dockerfiles (src/fetch, src/git, src/time).
  • Adds USER node before ENTRYPOINT to Node Dockerfiles (src/filesystem, src/memory).
  • Prevents container operations from creating root-owned files on bind mounts and complies with Kubernetes runAsNonRoot: true policies.

…ainer images

Closes modelcontextprotocol#4741. Switched fetch, git, and time images to app user and filesystem/memory to node user.
@teddiesloco
teddiesloco force-pushed the fix/dockerfile-non-root-user branch from e6baebb to b69718b Compare September 3, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfiles for fetch/git/time create an app user (since #2205) but never switch to it; all seven images run as root

1 participant