Question about Docker from beginner how to assemble the image?

I want to gather images from alpine and install bash was the default Node version manager, and install the nodejs v12.13.1, here is the Dockerfile

FROM alpine

RUN apk update

RUN apk add bash

RUN apk add wget

#RUN export SHELL=/bin/bash

RUN cd ~ && touch .bashrc

RUN wget-qO - https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

SHELL ["/bin/bash", "-c"]

RUN echo $0

RUN nvm install 12.13.1

RUN nvm use 12.13.1


but the build falls on the line RUN nvm install 12.13.1 with the message /bin/bash: nvm: command not found

moreover, if thecommunity
#RUN nvm install 12.13.1

#RUN nvm use 12.13.1

log in container docker run -it imagename bash

then nvm install 12.13.1 works and installs.
But nvm use 12.13.1 crashes with the error
env: can't execute 'node': No such file or directory
nvm is not compatible with the npm config prefix option: currently set to ""
Run `nvm use ' --delete-prefix v12.13.1` to unset it.
April 3rd 20 at 18:30
1 answer
April 3rd 20 at 18:32
add

. ~/.nvm/nvm.sh

before

nvm install
took chmod 777 ~/.nvm/nvm.shbut still does not work, errors does not issue

FROM alpine

RUN apk update

RUN apk add bash

RUN apk add wget

#RUN export SHELL=/bin/bash

SHELL ["/bin/bash", "-c"]

RUN cd ~ && touch .bashrc

RUN wget-qO- <a href="https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh">https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh</a> | bash

RUN chmod 777 /root/.nvm/nvm.sh

RUN /root/.nvm/nvm.sh install 12.13.1

RUN /root/.nvm/nvm.sh use 12.13.1

RUN /root/.nvm/nvm.sh current


if you go in then in the container from this image, then nvm current meets none - Scarlett commented on April 3rd 20 at 18:35
@Scarlett,
and you do everything with root? - Justice.Beatty commented on April 3rd 20 at 18:38
@Justice.Beatty, Yes
whoami
says root - Scarlett commented on April 3rd 20 at 18:41
@Scarlett,
and during the build?

apparently, something with the environment... - Justice.Beatty commented on April 3rd 20 at 18:44
@Justice.Beatty, during the build and checked RUN whoami

ubuntu is also not working well, do not care, did Ubuntu itself in the container with the image clicked nvm install 12.13.1, then commits)))docker commit - Scarlett commented on April 3rd 20 at 18:47

Find more questions by tags LinuxbashNode Version ManagerDocker