good tutorial - https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
docker hub (signup) - https://hub.docker.com/
install guide - https://docs.docker.com/docker-for-mac/

Install

download Docker at https://docs.docker.com/docker-for-mac/ Once Docker is installed, we need to install VirtualBox using Homebrew (assuming you have it setup).
$ brew cask install virtualbox
$ brew install docker docker-machine

If VirtualBox is not up to date, Docker will refuse to run. Make sure you have the latest version.

NodeJS app to run inside Docker container

We will just use a basic Nodejs/express server that returns some dummy data on a request.

package.json

{
  "name": "dockernodetest",
  "version": "0.0.1",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.13.3"
  }
}

server.js

const app = require('express')()
const PORT = 8080

app.get('/', function (req, res) {
  res.send('Hello world\n')
})

app.get('/test', function (req, res) {
  res.json({ '1': 'one', '2': 'two', '3': 'three' })
})

app.listen((PORT) => console.log(`server running on port ${PORT}`))

Dockerfile

FROM node:argon

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

EXPOSE 8080
CMD [ "npm", "start" ]

Building Docker image

In the codes directory, run the following:

$ docker build -t <YOUR_USERNAME>/dockernodetest .

The image should now be lsited in docker:

$ docker images

// OUTPUT:
// REPOSITORY                      TAG        ID              CREATED
// node                            argon      539c0211cd76    3 weeks ago
// <your username>/node-web-app    latest     d64d3505b0d2    1 minute ago

Running the image

-d – runs the container in detached mode, leaving the container running in the background -p – redirects a public port to a private port

$ docker run -p 49160:8080 -d <YOUR_USERNAME>/dockernodetest

Lets make sure all is running well:

$ docker ps
$ docker logs <CONTAINER_ID>

You can now visit http://localhost:49160/test where the app should be running

Misc.

If you want to go inside the container and run commands:

$ docker exec -it <CONTAINER_ID> /bin/bash