high · dockerfile/run-as-root
Container runs as root
Containers default to root. Prefer a non-root USER before CMD/ENTRYPOINT.
Why it breaks the cache
A compromised process running as root has full container privileges.
Bad Dockerfile
FROM node:18
CMD ["node", "server.js"]
Good Dockerfile
FROM node:18
RUN adduser -S appuser
USER appuser
CMD ["node", "server.js"]
CLI
layerlint rules explain run-as-root