Create ubuntu docker image with nodeJS 4

I need to create a ubuntu docker image with nodeJS 4. What I was doing is this:

FROM ubuntu:16.04

RUN apt-get update -y && \
    apt-get install -yqq python build-essential apt-transport-https ca-certificates curl locales nodejs npm sudo git

RUN curl -sL | bash -
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

But does that make sense at all? Installing apt-get install nodejs npm and curl -sL | bash -

  • Docker reload does not reflect changes in CSS files
  • How to run official mongodb docker storing data to separate host system drive?
  • install additional python package on docker
  • Virtual Box on Windows while using Docker
  • How to run jar file using docker file in docker container
  • why docker machine always open in super user mode?
  • And also I have to do update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

    I would like to get this a bit smaller and smarter.

  • side effect of --rm: when exit a container build with docker run --rm -v /myvol, also the volume is removed
  • run apps using audio in a docker container
  • Change CPU capacity of Docker containers
  • My boot2docker installation seems to not be working. What am I doing wrong?
  • run a meteor app on docker - doesn't open in localhost
  • Docker push failing over proxy
  • One Solution collect form web for “Create ubuntu docker image with nodeJS 4”

    Here is how I install nodejs in a Debian Jessie container :

    COPY ./rsrc/nodesource.gpg.key /tmp/nodesource.gpg.key
    RUN apt-key add /tmp/nodesource.gpg.key
    RUN echo 'deb jessie main' > /etc/apt/sources.list.d/nodejs.list
    RUN apt-get update
    RUN apt-get install -y nodejs

    I think adding the offical repo list to apt is the best option here.

    Edit :

    The first two lines add the crypto nodesource key to apt (used later to crypto verify pkg), then add node list to you apt list, update and install your node package

    Edit² :

    Also, add a dedicated default user into you node image.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.