I am not sure if this means that you try to create the root user, which is not necessary in any image based on a os baseimage, as the root user with UID0, GID0 always exist for them.
The 2nd way is the prefered one though. Can you share your current Dockerfile?