Docker run with nonroot user

Hi

I want to run the docker via non-root user. I have see many docker hub images which directly login into the non-root user.

How I can also do the same.

I know the explicit command like -u= user to run docker with non-root user But I have without -u it should login into the non-root user.

Their Dockerfiles have a USER statement. (And almost certainly run things like a bistro-specific adduser command to create the user they switch to.)

You could have a wrapper script that runs docker run with the correct options, or use a tool like Docker Compose. (And there are enough docker run options that you want frequently, that vary by container, that you probably should set this up anyways.)