How to install nvm in docker?

后端 未结 14 936
陌清茗
陌清茗 2020-12-04 05:53

I am in the process of building a new Docker image and I\'m looking to get NVM installed so I can manage nodejs.

Reading the docs on how to install NVM they mention

14条回答
  •  醉梦人生
    2020-12-04 06:41

    Took me an hour or two to figure out the cleanest way to do it. --login doesn't seem to execute .bashrc so you have to supply -i to launch it in interactive mode. This causes Docker to yell at you for a bit so I only launch this way for the installation, then reset to my standard shell.

    # Installing Node
    SHELL ["/bin/bash", "--login", "-i", "-c"]
    RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
    RUN source /root/.bashrc && nvm install 12.14.1
    SHELL ["/bin/bash", "--login", "-c"]
    

提交回复
热议问题