Creating a new user in nginx dockerfile

I have the following dockerfile set up, in which i am trying to creating a newuser instead of using the root user.

Dockerfile

USER root
RUN microdnf --setopt=tsflags=nodocs install -y nginx procps shadow-utils net-tools ca-certificates dirmngr gnupg wget vim
            && microdnf clean all 
            && rpm -q procps-ng

ENV NGINX_USER="api-gatway" 
    NGINXR_UID="8987" 
    NGINX_GROUP="api-gatway" 
    NGINX_GID="8987"     

RUN set -ex; 
  groupadd -r --gid "$NGINX_GID" "$NGINX_GROUP"; 
  useradd -r --uid "$NGINXR_UID" --gid "$NGINX_GID" "$NGINX_USER" 

#To start up NGINX 
EXPOSE 80
USER $SOLR_USER
CMD ["nginx", "-g", "daemon off;"]

When I exec into my docker container, it still remains as the root user instead of switching to the new user that I have created.

uk m$ docker exec -it 828f6d67a004 /bin/bash 
[[email protected] /]# 

I have checked my /etc/passwd file, it displays that the user has been created

api-gatway:x:8987:8987::/home/api-gatway:/bin/bash

I am able to switch to the new user i have created by doing the su command, shown below:

[[email protected] /]# su api-gatway
bash-4.4$ whoami 
api-gatway

What changes should i make in my dockerfile that when i run my docker image and start the docker container, it starts up as user:api-gatway rather than root?

Source: Docker Questions