# 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:

|Param|Description| Required | |-----|----|----| |{string} filePath | The path to the docker compose file | Yes | |{string} projectName | The name of the compose project | No | |{string} host | The host docker machine | No |

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.

|Param|Default|Required| |------|-----|-----| |protocol|vnc://'| No | |username|'secret'| No | |password|'secret'| No | |host|local IP| No | |port|5900| No |

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 ```js 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 ```js easyDocker.containerEnd(); ``` #### If your container allows VNC ```js easyDocker.showVnc(); ``` #### Specific operations The docker, machine and vnc classes give you lower level control ```js 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

Changelog

2.0.1

  • Fix VNC to wait for connection

2.0.0

  • Added docker compose. Runs native Docker.
  • Deprecated virtualbox (Docker Toolbox)

1.0.0

  • first working npm publish

Contributing

Here's the most direct way to get your work merged into the project:

  • Fork the project.
  • Clone down your fork ( git clone git@github.com:[username]/mns-core-docker.git ).
  • Create a topic branch to contain your change ( git checkout -b my_awesome_feature ).
  • Hack away, add tests. Not necessarily in that order.
  • Make sure everything still passes by running npm run test.
  • If necessary, rebase your commits into logical chunks, without errors.
  • Push the branch up ( git push origin my_awesome_feature ).
  • Create a pull request against mns-core-aut/develop and describe what your change does and the why you think it should be merged.