diff --git a/README.md b/README.md index 1de78ba..3d1c451 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ - [Installing and Updating](#installing-and-updating) - [Install & Update Script](#install--update-script) - [Additional Notes](#additional-notes) + - [Installing in Docker](#installing-in-docker) - [Troubleshooting on Linux](#troubleshooting-on-linux) - [Troubleshooting on macOS](#troubleshooting-on-macos) - [Ansible](#ansible) @@ -84,6 +85,24 @@ Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not conta - The installer can use `git`, `curl`, or `wget` to download `nvm`, whichever is available. +#### Installing in Docker + +To install `nvm` in Docker, you may need to prepare you image's environment +in advanced in order to use `node` & `npm`. Here's a winning recipe: + +```Dockerfile +# set your target node version +ENV NODE_VERSION 14.13.1 +# set NVM_DIR +ENV NVM_DIR="$HOME/.nvm" +# patch PATH +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH +# install! +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash \ + && source $NVM_DIR/nvm.sh \ + && nvm install ${NODE_VERSION} +``` + #### Troubleshooting on Linux On Linux, after running the install script, if you get `nvm: command not found` or see no feedback from your terminal after you type `command -v nvm`, simply close your current terminal, open a new terminal, and try verifying again.