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 https://deb.nodesource.com/setup_4.x | 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 https://deb.nodesource.com/setup_4.x | bash -

  • Keeping environment variables on window split
  • How do you register a Postgres container host on docker-compose up?
  • How to auto restart a Docker container after a reboot in CoreOS?
  • `docker run` using Golang API (Docker docs)
  • Keeping alive Docker containers with supervisord
  • How to run python script in docker with the script being sent dynamically to docker container?
  • 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.

  • Docker and high performance cluster (HPC) ability
  • Can not access Nodejs app which deployed on container of Bluemix
  • Intergration of Docker with OpenStack via Docker Heat Plugin
  • Dockerhub Automated Builds tagging
  • Download failure within official ubuntu docker images on Ubuntu 14.04 host
  • How to get /etc/profile to run automatically in Alpine / Docker
  • 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 https://deb.nodesource.com/node_6.x 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.