mns-core-docker
v2.0.1
Published
MNS core docker tasks
Downloads
9
Readme
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
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']});