Dockerfile
Dockerfile copied to clipboard
Unable to install specific version of nodejs in my php-nginx:7.4-alpine docker image
So I've found an answer on how to install specific version of nodejs.
My dockerfile goes as follows:
FROM webdevops/php-nginx:7.4-alpine
WORKDIR /var/www/html
I want to install nodejs, version 14.18.1. So after FROM and before WORKDIR, I've added:
RUN apk add --update nodejs=14.18.1
Then as soon as I rebuild the image I get:
[+] Building 2.6s (5/6)
=> [internal] load build definition from app.dockerfile 0.0s
=> => transferring dockerfile: 172B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/webdevops/php-nginx:7.4-alpine 0.0s
=> CACHED [1/3] FROM docker.io/webdevops/php-nginx:7.4-alpine 0.0s
=> ERROR [2/3] RUN apk add --update nodejs=14.18.1 2.5s
------
> [2/3] RUN apk add --update nodejs=14.18.1:
#5 0.185 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
#5 1.220 fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
#5 1.567 fetch https://dl-4.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
#5 2.430 ERROR: unsatisfiable constraints:
#5 2.456 nodejs-12.22.6-r0:
#5 2.456 breaks: world[nodejs=14.18.1]
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c apk add --update nodejs=14.18.1]: exit code: 1
If I replace this line with RUN apk add --update nodejs npm then it works but it installs version 12 which not what I want.
What am I doing wrong?
This is what i used to target specific versions (using php-nginx:7.4). Sorry I haven't attempted this with alpine though.
RUN apt-get clean
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs