Reputation: 914
I have the following 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
Building the image gives me:
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
How is it possible for node to not be found? It's installed in the correct directory, it's in the path, and has execution permission...
Upvotes: 3
Views: 21560
Reputation: 13662
There is an official and up to date node package for alpine, you don't need to install it manually, just add this line in your Dockerfile:
RUN apk add nodejs=6.2.0-r0
Or you could use an existing nodejs alpine image:
FROM mhart/alpine-node:6.2.0
On a side note, the whole point of using an alpine based image is to get rid of the clutter, installing git, tar et al. is a waste of space IMHO.
Upvotes: 6