我有以下Dockerfile:
FROM alpine:3.3
RUN apk update \
&& apk add curl tar git gzip
RUN curl --retry 3 --retry-delay 20 --show-error --location --remote-name --silent "https://nodejs.org/dist/v6.2.0/node-v6.2.0-linux-x64.tar.gz" \
&& tar -xzf "node-v6.2.0-linux-x64.tar.gz" -C /usr/local --strip-components=1 --same-owner \
&& rm -rf "node-v6.2.0-linux-x64.tar.gz" \
&& ls -la /usr/local/bin && env \
&& /usr/local/bin/node -v \
&& npm cache clear
构建图像让我:
Sending build context to Docker daemon 13.51 MB
Step 1 : FROM alpine:3.3
---> 3e467a6273a3
Step 2 : RUN apk update && apk add curl tar git gzip # bzip2 build-essential libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev python python-dev python-pip python-virtualenv libkrb5-devENV NODE_VERSION=6.2.0
---> Using cache
---> 65f46657024a
Step 3 : RUN curl --retry 3 --retry-delay 20 --show-error --location --remote-name --silent "https://nodejs.org/dist/v6.2.0/node-v6.2.0-linux-x64.tar.gz" && tar -xzf "node-v6.2.0-linux-x64.tar.gz" -C /usr/local --strip-components=1 --same-owner && rm -rf "node-v6.2.0-linux-x64.tar.gz" && ls -la /usr/local/bin && env && /usr/local/bin/node -v && npm cache clear
---> Running in 32967b91e2dd
total 26828
drwxrwxr-x 2 500 500 4096 May 17 19:40 .
drwxr-xr-x 10 root root 4096 May 24 14:28 ..
-rwxrwxr-x 1 500 500 27459658 May 17 19:40 node
lrwxrwxrwx 1 500 500 38 May 17 19:40 npm -> ../lib/node_modules/npm/bin/npm-cli.js
HOSTNAME=27c9668b3d5e
SHLVL=1
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
/bin/sh: /usr/local/bin/node: not found
The command '/bin/sh -c curl --retry 3 --retry-delay 20 --show-error --location --remote-name --silent "https://nodejs.org/dist/v6.2.0/node-v6.2.0-linux-x64.tar.gz" && tar -xzf "node-v6.2.0-linux-x64.tar.gz" -C /usr/local --strip-components=1 --same-owner && rm -rf "node-v6.2.0-linux-x64.tar.gz" && ls -la /usr/local/bin && env && /usr/local/bin/node -v && npm cache clear' returned a non-zero code: 127
Build image failed
如何找不到节点? 它安装在正确的目录中,它在路径中,并具有执行权限......
答案 0 :(得分:2)
有一个official and up to date node package for alpine,你不需要手动安装它,只需在你的Dockerfile中添加这一行:
<div th:fragment="editor(binding)">
<div th:attr="data-bind=${binding}"></div>
</div>
或者您可以使用existing nodejs alpine image:
RUN apk add nodejs=6.2.0-r0
另一方面,使用基于阿尔卑斯山的图像的全部意义是摆脱杂乱,安装git,tar等。是恕我直言的浪费。