First thing first: .bashrc is automatically sourced only for interactive non-login shells (see this article). Since your shell is non-interactive, you need to source it manually.
You seemem to have realized this and attempted to account for that by doing:
RUN cd root && /bin/bash -c “source .bashrc” && /bin/bash -c “pyenv install 3.7.1”
The line above runs 3 shells: the parent shell that runs the entire command, a child shell that runs source .bashrc and a second child shell that runs pyenv install 3.7.1.
Do you see the problem? The child shell that attempts to run pyenv is not the same child shell that sourced .bashrc and therefore knows where pyenv is located.
The proper command to run a single shell that knows where pyenv is located and can execute it would be:
RUN source /root/.bashrc && pyenv install 3.7.1
or
RUN ["/bin/bash", “-c”, “source /root/.bashrc && pyenv install 3.7.1”]
Note that the first variant will use /bin/sh to run your command. In most modern Linux systems this is an alias to either /bin/bash or /bin/dash. If you want to be 100% sure that you’re running Bash, use the second form.