Skip to content

fix(docker): switch to non-root user in all MCP server Dockerfiles - #4742

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

fix(docker): switch to non-root user in all MCP server Dockerfiles#4742
somuai wants to merge 1 commit into
modelcontextprotocol:mainfrom
somuai:fix-dockerfile-non-root-user

Conversation

@somuai

@somuai somuai commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Resolves #4741.

Problem

  • The Python Dockerfiles (fetch, git, time) created an app user with useradd -rUM -s /usr/sbin/nologin app and chowned /app/.venv to app:app, but never switched to it with a USER instruction.
  • The Node.js Dockerfiles (everything, filesystem, memory, sequentialthinking) used node:22-alpine without switching to the pre-existing node user.
  • As a result, all seven images ran as root (UID 0). In the case of src/filesystem, bind mounts to host directories created files owned by root, and Kubernetes admission controllers requiring runAsNonRoot: true rejected the images.

Solution

  • Added USER app before ENTRYPOINT in the Python images (src/fetch/Dockerfile, src/git/Dockerfile, src/time/Dockerfile).
  • Added USER node before CMD/ENTRYPOINT in the Node.js images (src/everything/Dockerfile, src/filesystem/Dockerfile, src/memory/Dockerfile, src/sequentialthinking/Dockerfile).

Resolves modelcontextprotocol#4741.

- Switch to 'app' user in Python images (fetch, git, time)
- Switch to 'node' user in Node.js images (everything, filesystem, memory, sequentialthinking)
- Prevents root container execution and root-owned host files on bind mounts
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