N|Solid Documentation

Versions

Docker

For people who need to use N|Solid in a Dockerized environment, NodeSource has developed the N|Solid Docker images.

These images are built with the enterprise customer in mind, developing a versatile set of independently scalable Docker images that work together to provide a unified N|Solid experience across all of your Dockerized infrastructure.

In addition to being friendly to enterprise operations teams, the N|Solid Docker Images have been designed to be accessible to developers. For those who are already using Docker, these images provide an easy way to get up and running with the N|Solid console. With the use of docker-compose, you can now get the full N|Solid Suite on your local machine with a single command.

Overview of N|Solid Docker Images

"N|Solid Architecture"

We provide 4 separate Docker Images for N|Solid, allowing each component of the platform to be scaled and deployed independently.

All of the images are built on the official ubuntu:trusty image maintained by the Docker project. The latest tag defaults to the latest Boron release. For more details please refer to the docker-nsolid github repository.

Installing the N|Solid Docker Images

Setting up Docker

First, follow the steps for installing Docker for your operating system, we recommend you use at least Docker v1.9: https://www.docker.com/products/docker

Although not required, it is recommended that you use docker-compose when first getting started. It simplifies managing these Docker images when running them locally.

Docker Compose

You can use the docker-compose file below to further understand the N|Solid platform configuration and/or to use it as a starting point for your docker setup.

NOTE: the following docker-compose file doesn't include any N|Solid application yet. We will explain how to add your application below.

nsolid.yml

version: "2"
services:
  storage:
    image: nodesource/nsolid-storage
    container_name: nsolid.storage
    ports:
      - 4000:4000
      - 9001:9001
      - 9002:9002
      - 9003:9003
  console:
    image: nodesource/nsolid-console
    container_name: nsolid.console
    environment:
      - NSOLID_CONSOLE_STORAGE_URL=https://storage:4000
    links:
      - storage
    ports:
      - 3000:3000

Downloading the Docker Images

If you are using docker-compose, open a terminal in the folder you created nsolid.yml in, and run the following command:

docker-compose -f nsolid.yml pull

This command will download all of the images needed to run the N|Solid console locally. If you choose not to use docker-compose, execute the following commands:

docker pull nodesource/nsolid-storage
docker pull nodesource/nsolid-console

# Optional CLI
docker pull nodesource/nsolid-cli

Using the N|Solid Docker Images

Starting the N|Solid Console

To bring up the N|Solid Console at this point, run the following command:

docker-compose -f nsolid.yml up

By default, this will bring up the N|Solid Console running on 127.0.0.1:3000.

Even though we highly recommend starting up the N|Solid using docker-compose since it's declarative nature makes it very easy to configure each piece of the N|Solid platform you can do so by just using docker as well as follows:

# start storage
docker run -d -p 9001-9003:9001-9003 -p 4000:4000 --name storage nodesource/nsolid-storage
# start console
docker run --link storage:storage -d -p 3000:3000       \
  -e 'NSOLID_APPNAME=console'                 \
  -e 'NSOLID_CONSOLE_STORAGE_URL=https://storage:4000' \
  nodesource/nsolid-console

This will bring up the N|Solid console available on localhost:3000.

Visit the docker docks for more information on linking containers

Creating an Example Docker Application

Create a file called server.js:

var http = require('http');
var hostname = require('os').hostname();
var port = process.env.PORT || 8888;

var server = http.createServer(function handleRequest (request, response) {
  response.end('[' + hostname + '] Serving requests from myapp. Request URL:' + request.url);
});

server.listen(port, function () {
  console.log('Server listening on port', port);
});

Next create a file called Dockerfile:

FROM nodesource/nsolid

COPY server.js /server.js

EXPOSE 8888

CMD ["nsolid", "/server.js"]

Building the docker image:

docker build -t example .

Starting Example Application with Docker Compose

Next, create the file docker-compose.yml in the directory along-side nsolid.yml:

docker-compose.yml

version: "2"
example:
  image: example
  container_name: nsolid.example
  links:
    - storage
  ports:
    - 8888:8888 # Port your application exposes
  environment:
    - NSOLID_APPNAME=example
    - NSOLID_COMMAND=storage:9001
    - NSOLID_DATA=storage:9002
    - NSOLID_BULK=storage:9003

For the complete documentation on defining a service with docker-compose.yml, refer to the Docker project’s documentation page: https://docs.docker.com/compose/overview/.

At this point, you are ready to bring up your application using docker-compose

docker-compose -f nsolid.yml -f docker-compose.yml up

Starting Example Application without Docker Compose

Start your service with:

# start and connect your application to N|Solid
docker run -d --link storage:storage --name example -e 'NSOLID_APPNAME=example' -e 'NSOLID_COMMAND=storage:9001' -e 'NSOLID_DATA=storage:9002' -e 'NSOLID_BULK=storage:9003' example

Adding Your Own Application with docker-compose

First, ensure your application is compatible with the LTS release of Node.js. NodeSource has created upgrade-ready to assist with this.

If you are new to Docker, follow the steps in our blog post to get your application into a Docker container.

Your Dockerfile should begin with the following line:

FROM nodesource/nsolid

Congratulations, you are now up and running with N|Solid and Docker!