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 Installation Error on Windows behind Firewall
  • Dokku Port configuration problems EC2
  • How to give docker container write/chmod permissions on mapped volume?
  • How to use Docker's COPY/ADD instructions to copy a single file to an image
  • How to use MariaDB in Docker?
  • Build .NET Core Console Application into Docker
  • 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.

  • How to add Alpine Linux repositories when their domain is expired?
  • Connecting to Kubernetes master, updating heapster
  • java.lang.RuntimeException: No main class detected
  • Excluding all hidden files with .dockerignore
  • Enabling Remote API in Docker on Mac OS X (boot2docker)
  • When docker run, an error occurs. “ValueError: Unable to configure handler 'watchtower': You must specify a region.”
  • 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.