13

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
7
  • Going to hate to break it to you. But source not found means whatever it is trying to install from a specific directory, cannot be found. So are you sure you followed the tutorial you are following entirely and not missing something? Commented Nov 17, 2016 at 5:40
  • yes have paste this code from tutorial.. i want to install nvm so following this link liquidweb.com/kb/… Commented Nov 17, 2016 at 5:43
  • Can you link to the source of the tutorial? Source not found is pretty self-explanatory Commented Nov 17, 2016 at 5:43
  • the tutorial says : After running the above command, you may receive output similar to the following: Close and reopen your terminal to start using nvm Either do as the output suggests, and close and reopen your terminal session, or run the command. Commented Nov 17, 2016 at 6:25
  • here i am using docker file for. how can i open and close terminal of docker image. i am directly building docker file from my ubuntu terminal. Commented Nov 17, 2016 at 6:34

2 Answers 2

6

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"]
Sign up to request clarification or add additional context in comments.

5 Comments

here i am getting same issue.
What happed at line RUN ["/bin/bash", "-c", "source ~/.profile"]?
The command '/bin/bash -c source ~/.profile' returned a non-zero code: 1
now again i am getting other error for --- RUN npm install---- also tried ---RUN ["/bin/bash", "-c", "npm install"]---
Look like you're trying to build a node.js application inside a Docker container? You might need to post the full source code or the source code link to review.
2

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.