dolphin

0.1.14 • Public • Published

Dolphin

dolphin

A fast, lightweight an modular library to interact with docker daemons.

This module provides a thin layer to communicate with docker daemons in node. The api is promise and events based trying to follow the semantics of docker's remote api as closely as possible.

Install

npm install dolphin

Usage

Instantiation

Before starting to interact with docker deamons you need to instantiate dolphin. If you are using docker-machine, and the env vars are set by docker-machine env mymachine, then you can just instantiate it without args. If no env variables are set, it will use dockers default Unix domain socket: unix:///var/run/docker.sock.

var dolphin = require('dolphin')();

You can also instantiate it with an explicit url pointing to the docker daemon:

var Dolphin = require('dolphin');
 
var dolphin = Dolphin({
    url: 'http://mydockerhost.com: 1234'
})

Version

You can ask dolphin for the docker engine version installed:

dolphin.version().then(function(version){
    ...
})

Or some system wide information:

dolphin.info().then(function(info){
    ...
})

Images

Containers

You can get a list of all the containers running on the system using the container method:

dolphin.containers().then(function(containers){
    // Containers contains an array of docker containers.
    // https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#list-containers
})
 
// Query parameters are also supported, so that you can get a subset of the containers
dolphin.containers({
    all: {Boolean}, // Show all containers even stopped ones.
    limit: {Integer},
    since: {Integer}, // Show containers created since given timestamp
    before: {Integer}, // Show containers created before given timestamp
    size: {Boolean},
    filters: {Object}, // Eg. {"exited":0, "status":["restarting","running","paused","exited"]}
}).then(function(containers){
 
})

Container methods

There are several useful methods for querying containers:

dolphin.containers.inspect(containerId).then(function(info){
    // Container info
})
dolphin.containers.logs(containerId).then(function(logs){
    // Container logs
})
dolphin.containers.changes(containerId).then(function(changes){
    // Container changes
})
dolphin.containers.export(containerId).then(function(export){
    // Container info
})
dolphin.containers.stats(containerId).then(function(stats){
    // Container stats
})

Events

A very powerful featue in dolphin is the ability to listen to events generated by docker deamons.

It can show live or old events, depending on the options used:

dolphin.events({
    since: Date.now() / 1000,
    until: Date.now() / 1000
}).on('event', function(evt){
    console.log(evt);
}).on('error', function(err){
    console.log('Error:', err);
});

See which events are produced by docker here: https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/monitor-docker-s-events

Volumes

Networks

Nodes

Services

Readme

Keywords

Package Sidebar

Install

npm i dolphin

Weekly Downloads

1,003

Version

0.1.14

License

MIT

Last publish

Collaborators

  • manast