Interview Prep/Docker/Dockerfile Instructions & Builds

What is the `USER` instruction and when does it take effect?

BeginnerConceptDockerfile Instructions & Builds
Answer

It sets the user (and optionally group) for later RUN, CMD and ENTRYPOINT and for docker exec by default. Create the user first:

RUN groupadd -r app && useradd -r -g app -u 10001 app
USER 10001:10001

Use a numeric UID so Kubernetes runAsNonRoot can verify it.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds