npm i docker-composer-manager --save
- dockerComposeUp
- dockerComposeDown
- dockerComposeStop
- dockerComposeStart
- dockerExec
- dockerInspectIPAddressOfContainer
- dockerInspectPortOfContainer
This method receives a URI of a file and builds, (re)creates, starts, and attaches to containers for a service.
Name | Type | Description |
---|---|---|
file | string |
Required. The file where the service is described. |
options | [string] |
Optional. Docker compose up commad options. |
var dcManager = require('docker-composer-manager');
var file = __dirname + '/docker-compose.yaml';
dcManager.dockerComposeUp(file).then(out => {
console.log(out);
}, err=>{
console.error(err);
});
For passing environment variables to the docker-compose
command, It is used the process.env
global variable as follow:
var dcManager = require('docker-composer-manager');
var file = __dirname + '/docker-compose.yaml';
process.env.MONGO_VERSION = '3.0.15';
dcManager.dockerComposeUp(file).then(() => {
return dcManager.dockerExec('withenvironment_mongo_1', ['mongo', '--version']);
}).then((out) => {
return Promise.resolve(expect(out.indexOf('3.0.15')).to.not.be.equal(-1));
}).then(() => {
return dcManager.dockerComposeDown(file);
}).then(() => done()).catch(err => done(err));
This method receives a URI of a file and stops containers, removes containers, networks, volumes, and images created by dockerComposeUp.
Name | Type | Description |
---|---|---|
file | string |
Required. The file where the service is described. |
options | [string] |
Optional. Docker compose down commad options. |
var dcManager = require('docker-composer-manager');
var file = __dirname + '/docker-compose.yaml';
dcManager.dockerComposeDown(file).then(out => {
console.log(out);
}, err=>{
console.error(err);
});
This method receives a URI of a file and stops running containers without removing them.
Name | Type | Description |
---|---|---|
file | string |
Required. The file where the service is described. |
options | [string] |
Optional. Docker compose stop commad options. |
var dcManager = require('docker-composer-manager');
var file = __dirname + '/docker-compose.yaml';
dcManager.dockerComposeStop(file).then(out => {
console.log(out);
}, err=>{
console.error(err);
});
This method receives a URI of a file and sStarts existing containers for a service.
Name | Type | Description |
---|---|---|
file | string |
Required. The file where the service is described. |
options | [string] |
Optional. Docker compose start commad options. |
var dcManager = require('docker-composer-manager');
var file = __dirname + '/docker-compose.yaml';
dcManager.dockerComposeStart(file).then(out => {
console.log(out);
}, err=>{
console.error(err);
});
This method receives a container name and the command will be executed inside of it, and execute docker exec
command with insede_command given.
Name | Type | Description |
---|---|---|
container | string |
Required. The container where the command will be executed. |
exec_command | [string] |
Required. The command which will be executed. |
options | [string] |
Optional. Docker exec commad options. |
var dcManager = require('docker-composer-manager'),
container = 'node_container_01',
command = ['node', '--version'];
dcManager.dockerExec(container, command).then(out => {
console.log(out);
}, err=>{
console.error(err);
});
This method receives a container and retrun a promise that resolves the ip of it.
Name | Type | Description |
---|---|---|
container | string |
Required. The container for quering. |
options | object |
Optional. This object has only one field: options.network . This is the network where the container is attached. |
var dcManager = require('docker-composer-manager'),
container = 'node_container_01';
dcManager.dockerInspectIPAddressOfContainer(container,{network: "bridge"}).then(ip => {
console.log(ip);
}, err=>{
console.error(err);
});
This method receives a container and retrun a promise that resolves the port on it will expose.
Name | Type | Description |
---|---|---|
container | string |
Required. The container for quering. |
var dcManager = require('docker-composer-manager'),
container = 'node_container_01';
dcManager.dockerInspectPortOfContainer(container).then(port => {
console.log(port);
}, err=>{
console.error(err);
});