patternbashdockerMinor
npm not found but installed from the shell script file in Dockerfile
Viewed 0 times
scriptthefilebutnpmshellfounddockerfileinstalledfrom
Problem
I have a following Dockerfile:
The
However, it says
Also, when I remove the
FROM ubuntu:18.04
RUN mkdir app && cd app
WORKDIR app/
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
sudo \
&& curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh \
&& chmod u+x prereqs-ubuntu.sh \
&& ./prereqs-ubuntu.sh \
&& npm install -g \ # this line failed
&& yo \
composer-cli@0.20 \
composer-rest-server@0.20 \
generator-hyperledger-composer@0.20 \
composer-playground@0.20
CMD /bin/bashThe
prereqs-ubuntu.sh is from https://github.com/hyperledger/composer/blob/master/packages/composer-website/jekylldocs/prereqs-ubuntu.sh.However, it says
/bin/sh: 1: npm: not found on the line npm install -g when I try to build the image. But npm is installed when running prereqs-ubuntu.sh already and can be ran successfully at the end of the file (npm --version).Also, when I remove the
npm-install part from the Dockerfile (shown below) and do docker run --name test -it myimage to see if npm is installed, but it is installed.FROM ubuntu:18.04
RUN mkdir app && cd app
WORKDIR app/
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
sudo \
&& curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh \
&& chmod u+x prereqs-ubuntu.sh \
&& ./prereqs-ubuntu.sh \
CMD /bin/bashSolution
The issue is that
Where is the npm installed
The
prereqs-ubuntu.sh uses bash to install the npm. While the RUN directive uses sh to run the commands. Where is the npm installed
root@2cd4a6af90f4:/app# type npm
npm is /root/.nvm/versions/node/v8.16.0/bin/npmThe
PATH for the RUN directive# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binCode Snippets
root@2cd4a6af90f4:/app# type npm
npm is /root/.nvm/versions/node/v8.16.0/bin/npm# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binContext
StackExchange DevOps Q#8548, answer score: 3
Revisions (0)
No revisions yet.