I am trying to build docker and installing nvm
some code line
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
RUN source ~/.profile
curl run successfully but when running source, getting below error
/bin/sh: 1: source: not found
The command '/bin/sh -c source ~/.profile' returned a non-zero code: 127
From Docker docs:
The default shell for the shell form can be changed using the SHELL command.
In the shell form you can use a \ (backslash) to continue a single RUN instruction onto the next line. For example, consider these two lines: RUN /bin/bash -c 'source $HOME/.bashrc ;\ echo $HOME' Together they are equivalent to this single line: RUN /bin/bash -c 'source $HOME/.bashrc ; echo $HOME'
Note: To use a different shell, other than ‘/bin/sh’, use the exec form passing in the desired shell. For example, RUN ["/bin/bash", "-c", "echo hello"]
You could try:
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
# RUN source ~/.profile
RUN ["/bin/bash", "-c", "source ~/.profile"]
I solved this answer
instead of installing nvm by "source ~/.profile"
i change it to
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=4.5.0
RUN . $HOME/.nvm/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With