Asking password when i try to install ruby gem

Have you looked into the couple of binder examples of installing RubyGems and followed those?
Here is one and you’ll see in the Dockerfile that it calls in how to install gems.

There is another example here. This one invokes the minimal image. Which includes installs of several gens as well.