Yes, it's redundant, but there's almost no downside to leaving this redundancy in. This may have been done to develop against other images, or to support uses that may swap out the base image. It could be done to prevent future issues if the upstream image changes it's behavior. Or they may just want to be explicit so it's clear this container needs to run commands as root.
This assumes that you have verified that the base image is running as root (as the OP has done). For others with this question, if you run:
docker image inspect --format '{{.Config.User}}' $base_image_name
and see anything other than an empty string or root
, then you need USER root
to change the user for tasks that require that access (e.g. installing packages, changing filesystem permissions, and writing files in folders not owned by your user). After performing those steps (in separate RUN
lines) be sure to change back to the non-privileged user in your released image with another USER youruser
line.