11

I am trying to build my own docker container based on alpine linux and I need to add multiple services in that container (yes it is not recommended as best practice but at the moment my org devops is bit behind the curve and demanding a single dockerfile for my custom image).

I was checking this article to find the way to install the latest version of nodejs with npm on alpine linux. However there seems to be no apk add nodejs@6 or something like that provided in this discussion.

Also it appears that alpine linux does not have the latest version of nodejs (v 8.X) in the repository here.

So do I pretty much have to install nodejs from source? But that option is very slower compared to just installing from alpine repo.

EDIT:

adding nodejs-current in dockerfile is giving another problem

Step ... : RUN apk update && apk add nodejs-current

---> Running in e430b4d279e5 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 fetch http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz v3.4.6-213-gb6db4bd [http://dl-cdn.alpinelinux.org/alpine/v3.4/main] v3.4.6-160-g14ad2a3 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community] v3.6.0-3765-g46dd4472f4 [http://nl.alpinelinux.org/alpine/edge/testing] OK: 8679 distinct packages available ERROR: unsatisfiable constraints: nodejs-current (missing): required by: world[nodejs-current]

2
  • You know, there's Unix & Linux for that.
    – user772515
    Commented Sep 22, 2017 at 2:01
  • 2
    Well ... the nature of this question is such that it could be posted here also.
    – Andy
    Commented Sep 24, 2017 at 1:30

2 Answers 2

23

We provide two nodejs packages:

  • nodejs in main – LTS version,
  • nodejs-current in community – the current version, as its called by upstream.

So if you want the latest version, install nodejs-current by running:

apk add nodejs-current

Currently it’s 7.10.1 in v3.6 (stable branch) or 8.5.0 in edge (unstable/rolling branch).

We don’t use @N suffixes like nodejs@6, it’s not a valid package name.

4
  • I’ve explicitly stated that you should install nodejs-current from Alpine branch v3.6 or edge, but you’re using v3.4 repositories… v3.4 is quite old. And mixing v3.4 with current testing is extremely bad idea btw… Commented Sep 26, 2017 at 18:48
  • Oh OK! In that case, I will have to wait until the standard PHP image I am using (php:7.1.9-fpm-alpine) update their alpine repo to V3.6 (they use V3.4).
    – Andy
    Commented Sep 26, 2017 at 19:01
  • No, in that case you should stop using such horribly outdated image! Just use base alpine image and install php7-fpm package. Commented Sep 26, 2017 at 19:02
  • 3
    BTW The answer is right, it’s not my fault that you haven’t read it properly, so it’s quite rude to downvote it. Commented Sep 26, 2017 at 19:05
1

The simplest way for me was to use a specific version of Alpine.

In my use case I've used php:7.4-fpm-alpine image. And have to update it to php:7.4-fpm-alpine3.13 to be able to use Node 14.

php:7.4-fpm-alpine3.13 - Node 14
php:7.4-fpm-alpine3.12 - Node 12

Dockerfile example:

FROM php:7.4-fpm-alpine3.13

RUN apk update && apk add nodejs npm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .