1

I have tried the following to install nodes into a centos box but I get an error when it reaches ./configure

Step 6 : RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
---> Running in ebc71472544d
---> c97289348900
Removing intermediate container ebc71472544d
Step 7 : RUN cd /node-v0.10.28-linux-x64
---> Running in 3470f862c586
---> 1771d01a5da0
Removing intermediate container 3470f862c586
Step 8 : RUN ./configure
 ---> Running in 16a811766136
/bin/sh: ./configure: No such file or directory

My Dockerfile

#Install NodeJS
RUN cd /usr/src
RUN wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz
RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
RUN cd /node-v0.10.28-linux-x64
RUN ./configure
RUN make &&
RUN make install

Am I using the right way of installing nodes to centos using the Dockerfile?

2 Answers 2

4

I'm assuming this isn't the whole Dockerfile, right? Otherwise you're missing at least a FROM.

Try to change the last 4 lines like that:

RUN cd /node-v0.10.28-linux-x64 && ./configure
RUN cd /node-v0.10.28-linux-x64 && make
RUN cd /node-v0.10.28-linux-x64 && make install

or like this

RUN cd /node-v0.10.28-linux-x64 && ./configure && make && make install

As far as I can tell, docker is running each RUN command as a separate shell, so just changing the directory won't be remembered in the next commands.

Here is an example Docker file to test this:

FROM ubuntu

RUN cd /etc
RUN pwd

And here is the build log:

Step 0 : FROM ubuntu
 ---> 99ec81b80c55
Step 1 : RUN cd /etc
 ---> Running in a4c25ee340a8
 ---> 82ad93bdd18c
Removing intermediate container a4c25ee340a8
Step 2 : RUN pwd
 ---> Running in f535178df40c
/
 ---> 495c68757268

[EDIT]

Another option is to use WORKDIR, like this:

#Install NodeJS
WORKDIR /usr/src
ADD http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz .
RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
WORKDIR node-v0.10.28-linux-x64
RUN ./configure
RUN make &&
RUN make install
Sign up to request clarification or add additional context in comments.

Comments

-1

My solution using nvm:

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
RUN source $HOME/.bashrc && nvm install 12.14.1

RUN ln -s $HOME/.nvm/versions/node/v12.14.1/bin/node /usr/bin/node
RUN ln -s $HOME/.nvm/versions/node/v12.14.1/bin/npm /usr/bin/npm

RUN node -v
RUN npm -v

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.