[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to install node.js on debian (Docker) with 'apt-get' - having issues



On Wed, Oct 06, 2021 at 03:19:57PM -0600, /dev /local/ca wrote:
> How would I get the latest version of node.js (16.x.x) installed on Debian
> (in a Docker container)
> 

Hi /dev/local/ca - I'm guessing that's the appropriate form of your name.

You're using Docker. You have three or four options for where
your docker containers come from.

Official builds from a team
Official builds from an OS - which probably form the basis for the above
Builds from the Community - could be anybody, you don't know who/how/why
Docker images you build yourself - these might be slightly modified
community builds or you doing this from scratch

NodeJS 16

This is straightforward: the Node.js Docker Team build official images
https://hub.docker.com/_/node

I'd suggest

https://github.com/nodejs/docker-node/blob/e886c2c1d3a109ccfe169419f3b30f9794bacf61/16/bullseye/Dockerfile which is 16-bullseye

or

https://github.com/nodejs/docker-node/blob/e886c2c1d3a109ccfe169419f3b30f9794bacf61/16/bullseye-slim/Dockerfile which is 16-bullseye-slim

and, yes, there are buster images there too just underneath.

Python

https://hub.docker.com/_/python

These are built by the community - you've got every current version of
Python you want but I don't know who has built them.

Debian

https://hub.docker.com/_/debian

These are official Debian images published by Debian developers and 
officially maintained within Debian.

Again, you have all the flavours you want here.

Or you can take any one of those and use it as the basis to build your
own combined image.

> Reference:
> 
> https://stackoverflow.com/questions/69446940/how-to-install-node-js-version-16-x-x-in-a-debian-based-image-dockerfile-why
> 
> ---
> Date: Tuesday October 5th, 2021
> 
> Node 10.x was released on 2018-04-24 (but that's the default version when
> using apt-get)
> 
> I have needs to have both Python and Node.js installed in running
> container. I can get the latest version of python in a container using:
> 
> FROM python:alpine
> 
> or
> 
> FROM python:buster <== Debian based
> 

Alpine definitely != Debian. Different libc and so on. [But yes, it's
often smaller, faster - and they're good at reproducible builds too :) ]

> How do I get the latest version of node.js (16.10.0) installed on Debian
> (in a Docker container)
> 
> Whe I do this:
> 
> FROM python:buster
> 
> RUN apt-get update && \
>   apt-get install -y \
>     nodejs npm
> 
> I get these versions of node:
> 
> node: 10.24.0
> 
> npm 5.8.0
> 
> and when run in the container give a long statement about no longer being
> unsupported.

You're pulling the versions from buster - which was started two years ago.
Debian keeps a stable distro stable [But buster is now "oldstable" - stable
is now Bullseye / Debian 11]

> 
> What's up with the package repo that 'apt-get' pulls from, that it will not
> install later versions of node (14.x or greater)?
> 
> If I pull from:
> 
> FROM python:alpine
> 
> and include these lines
> RUN apk -v --no-cache --update add \
>     nodejs-current npm
> 
> I will get node 16.x version, which makes it easy. I don't have to do
> anything else.
> 
> Is there something equivalent for python:buster (Debian based)
> 
> I would really like a one or two liner in my Dockerfile and not a pages of
> instructions with a dozen commands to simply get node in the image.
> 
> I would appreciate any tested/proven reply. I am sure a number of others
> have the same question. Other stackoverflow articles on this subject are
> convoluted and do not provide the simple solution I am hoping to find that
> is available with pytyon:alpine
> 
> There is a reason I need python:debian and cannot use python:alpine in this
> one use case, otherwise I would chose the latter.
> 
> Is there a way some how to get a package repo maintainers attention to show
> me how to get a recent version (14..16), into the apt-get repository?
> 
> It appears many people are having issues with this.

In the sense that you are the first person to raise it with Debian in
this forum - maybe not too many.

Pick a basis and work with it. From the above, it seems to me that
you can take the official Node docker container and add python if it
isn't already there - it will probably end up being Pyhon 3.9 / 3.10?

Or you can take the Debian docker image and add node and the python
straight from Debian.

Or you can do your own thing based on the community Python Docker container.

I'm not currently using Docker: I found this article (which might
be helpful - https://pythonspeed.com/articles/base-image-python-docker-images/

Most of this was composed by putting in terms into Google like

Docker Debian image node

or 

Docker Debian image Python

or similar and reading the descriptions of the Docker images. Simply
following what you find on Stack Overflow may not be your best bet:
you might want to try some of this for yourself and see.

All the very best, as ever,

Andy Cater


Reply to: