Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart terminal & run command using Dockerfile

I have a Dockerfile where I am installing nvm. After installation, i'll be needing to install node 5.11 using nvm. The problem is, after installing nvm, the terminal needs to be closed & run again in-order to to have nvm command available.

My docker file looks like:

# Installing Node
RUN Y | curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
# RUN bash --login
RUN exec bash
RUN nvm install 5.11.0

# Installing Project dependencies
RUN npm install yarn -g
RUN npm install -g [email protected]

And the output I am getting is :

Step 5/9 : RUN exec bash
 ---> Using cache
 ---> cfcdc4c98714
Step 6/9 : RUN nvm install 5.11.0
 ---> Running in 1874de4a7715
/bin/sh: 1: nvm: not found
The command '/bin/sh -c nvm install 5.11.0' returned a non-zero code: 127

In real linux after running https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash after closing & starting the terminal the nvm command gets available. How do I do it in dockerfile? Thanks in advance.

like image 509
Yeasin Hossain Avatar asked Jul 04 '18 13:07

Yeasin Hossain


1 Answers

Has commands can do this.
PATH="$PATH" and exec bash
So, you can add these command inside your dockerfile.
If exec bash not work.Try another one.
It's work for me !

like image 141
DustyPosa Avatar answered Sep 22 '22 08:09

DustyPosa