对于Ubuntu,node.js可执行文件名为
nodejs
,不是
node
$ cat Dockerfile
FROM wordpress:4.9.8-php7.1-apache
RUN apt-get update
RUN apt-get install -y nodejs
RUN nodejs -v
docker build .
Sending build context to Docker daemon 2.048kB
Step 1/6 : FROM wordpress:4.9.8-php7.1-apache
---> 18747ca95580
Step 2/6 : RUN apt-get update
---> Using cache
---> 416b334f6ea7
Step 3/6 : RUN apt-get install -y nodejs
---> Using cache
---> 0606aac728ee
Step 4/6 : RUN nodejs -v
---> Running in c300e7140695
v4.8.2
不过,您得到的是Node的一个非常旧的版本。您可以尝试使用这种替代方法来安装
Node v8 (the current LTS)
通过节点的存储库
FROM wordpress:4.9.8-php7.1-apache
RUN apt-get update && apt-get -y install gnupg2
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && apt-get install -y nodejs
RUN nodejs -v
RUN npm install -g gulp