The USER instruction sets the user name or UID to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.
I want CMD to be run as root, but the image to be run as a non privileged user. If running docker exec I should get a non privileged prompt. The dockerfile reference clearly says that the USER instruction sets the user for any CMD that follows it. But when I set USER after CMD, the command is run as USER although it should be run as root. Is the information in dockerfile reference not correct? Isn’t it possible to set USER after CMD?