0.4.0 • Published 7 years ago

libdocker v0.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

libdocker

A nodeJS wrapper for the docker command

API

The API is similar to the docker command itself except in the way it handles json.

docker.COMMAND([arguments, options], cb)

Examples:

docker.run(['some-image:latest'], {detach: true}, cb)
docker.inspect(['some-container'], cb)

The --format '{{ json . }}' flag will be appended automatically if the command supports it and the output - if it is valid json - will be parsed as json.

Additionally there is an .array extension of the command which always tries to return an array unless an error occured.

Full example:

const docker = require('libdocker')

docker.run(['ubuntu:17.10'], err => { // run an ubuntu:17.10 container
  if (err) throw err
  docker.ps.array(['-a'], (err, res, stderr) => { // get the list of all containers
    console.log(err, res, stderr)
    /*
    Example:
    null [ { Command: '"/bin/bash"',
        CreatedAt: '2018-02-19 14:25:44 +0100 CET',
        ID: '64073efbd38b',
        Image: 'ubuntu:17.10',
        Labels: '',
        LocalVolumes: '0',
        Mounts: '',
        Names: 'inspiring_bardeen',
        Networks: 'bridge',
        Ports: '',
        RunningFor: '10 seconds',
        Size: '0 B',
        Status: 'Exited (0) 8 seconds ago' } ] ''
    */
  })
})
0.4.0

7 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago