Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

Latest commit

 

History

History
155 lines (121 loc) · 2.89 KB

7-using-docker-images.md

File metadata and controls

155 lines (121 loc) · 2.89 KB

Use an image from Docker Hub

This tutorial covers:

  1. Creating a new system
  2. Hooking up a new container definition from the Registry
  3. Building a new container
  4. Run!

Create a new System

As done in Exercise 2, let's go ahead and create a new system with:

$ nscale system create
? What is the system name? registry
? What is the system namespace? nscale
? Confirm creating system "registry" with namespace "nscale"? (Y/n) y

Now we can check that everything is as expected:

$ nscale system list
Name                           Id
registry                       2de30af9-fdc4-41ff-9b88-cd47eacb7f77

Add a registry container definition

Let's open definitions/services.js in you favorite editor. It currently looks like:

exports.root = {
    type: 'blank-container'
};

// Example
//
// exports.web = {
//   type: 'docker',
//     specific: {
//       repositoryUrl: '[email protected]:nearform/nscaledemoweb.git',
//       execute: {
//         args: '-p 8000:8000 -d',
//         exec: '/usr/bin/node index.js'
//       }
//     }
// }; 

To begin defining our system, we need to change it to:

exports.root = {
  type: 'blank-container'
};

exports.redis = {
  type: 'docker',
  specific: {
    name: 'redis',
    execute: {
      args: '-d -p 6379:6379'
    }
  }
};

Build a container

Let's open system.js in you favorite editor. It currently looks like this:

exports.name = 'registry';
exports.namespace = 'nscale';
exports.id = '2c03b9c3-5623-42b8-8af7-7093c6be2e70';

exports.topology = {
  development: {
  }
};

// Example
//
// exports.topology = {
//   development: {
//     root: ['web']
//   }
// };

This system is empty, let's add our containers:

exports.name = 'registry';
exports.namespace = 'nscale';
exports.id = '2c03b9c3-5623-42b8-8af7-7093c6be2e70';

exports.topology = {
 development: {
   root: ['redis']
 }
};
nscale system compile registry development

Now, let's build our containers:

$ nscale container buildall registry latest development

We'll check the revision list again:

$ nscale rev list workshop
revision             deployed who                                                     time                      description
15dffc828de9d971ba1… false    Matteo Collina <[email protected]>                2014-10-30T10:54:04.000Z  built container: redis

Deploy

All we have to do now is deploy:

$ nscale rev deploy registry 15dff development

Our container should be running just fine, we can use the following to see it in action:

OS X :

$ redis-cli -h `boot2docker ip`

Linux:

$ redis-cli

you may need to install redis-tools

sudo apt-get install redis-tools

[Next up: exercise 8] (./8-deploy-to-aws.md)