2.0.1 • Published 8 years ago

mns-core-docker v2.0.1

Weekly downloads
6
License
ISC
Repository
github
Last release
8 years ago

Installation

Docker

You need to have Docker installed. Download the native version of Docker for your platform here

If you have Docker Toolbox installed then it is best to uninstall it before install Docker native.

Module

To install the module

$ npm i mns-core-docker

Usage

Docker compose

DockerCompose take 3 parameters:

ParamDescriptionRequired
{string} filePathThe path to the docker compose fileYes
{string} projectNameThe name of the compose projectNo
{string} hostThe host docker machineNo
var DockerCompose = require('mns-core-docker').dockerCompose;

var compose = new DockerCompose(path.join(__dirname, './selenium/selenium-grid.yml'));

compose.scale('chrome=3', 'firefox=3')
    .then(function() {
        return compose.up();
    })
    .then(function() {
        return compose.stop();
    })
    .then(function() {
        return compose.rm();
    });

See Docker Compose CLI for reference. Not all commands have been implemented.

VNC

VNC will open a vnc window into the docker container if the container supports this feature.

ParamDefaultRequired
protocolvnc://'No
username'secret'No
password'secret'No
hostlocal IPNo
port5900No
var vnc = require('mns-core-docker').vnc;

vnc.open();

// or

vnc.open({port: '5901'});

Deprecated - VirtualBox (Docker Toolbox)

All methods return a promise

Easy Docker

This is the quickest way to get up and running with docker.

Run a machine and a container

var easyDocker = require('mns-core-docker').easy;

easyDocker.machineGo()
    .then(function() {
        return easyDocker.containerGo('my docker image', 'my container name');
    });

To remove the container you created

easyDocker.containerEnd();

If your container allows VNC

easyDocker.showVnc();

Specific operations

The docker, machine and vnc classes give you lower level control

var coreDocker = require('mns-core-docker').docker;
var dockerMachine = require('mns-core-docker').machine;
var dockerVnc = require('mns-core-docker').vnc;

dockerMachine.create('my machine name')
    .then(function() {
        return dockerMachine.start('my machine name');
    });

var docker = new coreDocker('my machine name');

docker.ready()
    .then(function() {
        return docker.pull('my container image');
    })


dockerVNC.open({host: global.dockerMachineIP['my ip identifier']});

Further reading