Dockerfile install ruby rails on rhel7

I’m trying to create a Dockerfile to install ruby rails on rhel7. But get this error on rvm. I tried the same steps on local instances and worked fine, but fails via docker build.

FROM registry.access.redhat.com/rhel7

RUN subscription-manager register --username <user> --password <password> --auto-attach

RUN yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel sqlite-devel; 
    curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -; 
    curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -; 
    curl -L get.rvm.io | bash -s stable;
    source /etc/profile.d/rvm.sh;
    source /usr/local/rvm/scripts/rvm;
    rvm reload;
    rvm install 2.6.1;
    rvm list;
    rvm use 2.6.1 --default;
    gem install rails;
    ruby --version;
    rails --version
?  Donate: <code>https://opencollective.com/rvm/donate</code>
/bin/sh: rvm: command not found
/bin/sh: rvm: command not found
/bin/sh: rvm: command not found
/bin/sh: rvm: command not found
/bin/sh: ruby: command not found
error building at step {Env:[PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin container=oci] Command:run Args:[curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -;     curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -;     curl -L get.rvm.io | bash -s stable;    source /etc/profile.d/rvm.sh;    source /usr/local/rvm/scripts/rvm;    rvm reload;    rvm install 2.6;    rvm list;    rvm use 2.6 --default;    ruby --version] Flags:[] Attrs:map[] Message:RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -;     curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -;     curl -L get.rvm.io | bash -s stable;    source /etc/profile.d/rvm.sh;    source /usr/local/rvm/scripts/rvm;    rvm reload;    rvm install 2.6;    rvm list;    rvm use 2.6 --default;    ruby --version Original:RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -;     curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -;     curl -L get.rvm.io | bash -s stable;    source /etc/profile.d/rvm.sh;    source /usr/local/rvm/scripts/rvm;    rvm reload;    rvm install 2.6;    rvm list;    rvm use 2.6 --default;    ruby --version}: error while running runtime: exit status 127

Source: StackOverflow