🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

dockership

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dockership

Scriptable docker management tool build upon Docker remote API.

latest
Source
npmnpm
Version
2.2.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Dockership

Scriptable docker management tool build upon Docker remote API.

Usage

1. Get Start

var Dockership = require('dockership');

var dockerConfig = {
  ca:   'path/to/ca', // Can also be a Buffer of ca.pem
  cert: 'path/to/cert',
  key:  'path/to/key',
  host: '0.0.0.0',
  port: 2376
};

var ship = new Dockership({
  docker: dockerConfig, // Config obj used to construct docker remote client
  buildContext: 'path/to/dockerfile/parent/dir', // Absolute, or relative to cwd
  meta: metaConfig // Information describing docker images and how to run containers
});

2. API

Dockership use dockerode and bluebird internally. All API calls will return a bluebird promise.

images method

Resolve with remote images specified by metaConfig.

ship.images().then(function (images) {
  console.log(images); // JSON
});

containers method

ship.containers().then(function (containers) {
  console.log(containers); // JSON
});

build method

ship.build().then(function (image) {
  console.log(image); // JSON
});

ship instance is an EventEmitter instance. You can listen to events emitted during build process.

ship.on('buildMessage', function (obj) {
  // Log something
});

Dockership comes with logger helper to help log buildMessage to console.

var logger = Dockership.makeLogger();
ship.on('buildMessage', logger);

logger can be customized by passing a modifier function:

var logger = Dockership.makeLogger(function (str) {
  return 'Prefix ' + str;
});

ship.on('buildMessage', logger); // Prepend "Prefix " to every line of message

start method

ship.start().then(function (container) {
  console.log(container); // JSON
});

By default, start will start stopped container or create container from image specified in metaConfig. If such container or image cannot be found, start will reject.

stop method

Stop will stop all containers match the description in metaConfig.

ship.stop().then(function (containers) {
  console.log(containers); // JSON
});

exec method

Execute command inside container. Reject if running container cannot be found.

ship.exec().then(function () {
  // No argument
});

this context

All promise callback have this refer to current ship instance.

ship
  .build()
  .then(function (image) {
    return this.start();
  })
  .then(function (container) {

  });

TODO

  • Improve event emitting, especially error emitting.

Keywords

docker

FAQs

Package last updated on 16 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts