I'm trying to install an older version of Node.js (4.4.4) on Alpine. Here are my commands:

apk update
apk add nodejs-lts=4.4.4-r0

When I execute, I get an error (running as root because I'm using the Alpine:3.4 Docker image):

/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.6-64-gd029d25 [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.6-33-g38ef2d2 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5977 distinct packages available
/ # apk add nodejs-lts=4.4.4-r0
ERROR: unsatisfiable constraints:
    breaks: world[nodejs-lts=4.4.4-r0]

How do I install a specific, older version of a package in apk?


That is correct. Unfortunately, 4.4.4 is not available.

You should avoid being explicit on package versions unless controlling your own package mirror and package builds, rather allow the package system to handle it for the Alpine release in use.

For Alpine 3.4, only 4.6.0 is available. Search Alpine 3.4 x86_64 Packages Online for nodejs-lts

If you are so inclined, here's the source for the package to change in order to build a specific version of choice.

Review the package source

Alpine has a wiki page: Creating an Alpine package.

Note that 'nodejs-lts' package name is deprecated.

provides="nodejs-lts=$pkgver" # for backward compatibility

replaces="nodejs-current nodejs-lts" # nodejs-lts for backward compatibility

  • Got it. Thanks for the explanation. This would be a good candidate for a FAQ. – Matthew Adams Feb 5 '17 at 16:10
  • 6
    So it is not possible fixate the version? To make container image kind of immutable/ – WHITECOLOR Apr 9 '17 at 22:55
  • "You should avoid being explicit on package versions".. What about issues caused by specific versions?.. – dustytrash May 17 '20 at 9:52

Unfortunately, Alpine-Linux Package Management drops older packages when there are newer versions available. This makes it hard to use Alpine Linux with docker since you want a reproducible image with exact versions.

See this article for the entire rundown. The two solutions that are offered: Create you own mirror and host the specific version of the packages you wish to keep having access to (probably not worth the effort) or use a different base image such as Ubuntu who's package management system doesn't drop older versions of packages (as intuitively expected from any modern day package management system).

And, I suppose you could just update your docker file to use the latest available version of those packages. However, it'll only be a matter of time before you run into this same situation again. It's just not scalable if you are building for a production system.


You can use a specific version from previous alpine release using the following, with example of alia-lib-dev which is set to 1.1.7-r0 in alpine edge but here forced to be 1.1.6-r0 from alpine 3.8:

apk add --no-cache --update-cache --repository http://nl.alpinelinux.org/alpine/v3.8/main alsa-lib-dev=1.1.6-r0
  • This may work sometimes, but unfortunately the repository is only categorized by 2 version numbers (v x.y). git 2.22.0 used to work in alpine 3.10.1, but with alpine 3.10.3, it got dropped for git 2.22.2. This means that I am unable to use nl.alpinelinux.org/alpine/v3.10/main to get git 2.22.0. – cowlinator Jan 16 '20 at 23:18

Just uncomment the entry containing community in /etc/apk/repositories. Then run apk update and apk add <PKG>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.