0.0.1 • Published 7 years ago

dockercmd v0.0.1

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

dockercmd

Use docker functions in your javascript code

Installation

$ npm install dockercmd

Usage

var dockercmd = require( 'dockercmd' );

Containers list

dockercmd.ps().then(result => {
    console.log(result);
});

Return exemple :

[
   {
      "id":"a5d55b5c3ebe",
      "port":"",
      "image":"hello-world",
      "created":"2017-07-24 11:56:50 +0200 CEST",
      "status":"Exited (0) About an hour ago"
   },
   {
      "id":"734121f89a41",
      "port":"",
      "image":"postgres:9.6-alpine",
      "created":"2017-07-19 16:29:23 +0200 CEST",
      "status":"Exited (0) About an hour ago"
   }
]

Images list

dockercmd.images().then(result => {
    console.log(result);
});

Return exemple :

[
   {
      "id":"f6a9a3968e52",
      "repository":"postgres",
      "tag":"9.6-alpine",
      "size":"37.7 MB",
      "created":"2017-07-15 00:58:03 +0200 CEST"
   },
   {
      "id":"1815c82652c0",
      "repository":"hello-world",
      "tag":"latest",
      "size":"1.84 kB",
      "created":"2017-06-14 21:29:01 +0200 CEST"
   }{
      "id":"8a0824e0a178",
      "repository":"docker.elastic.co/elasticsearch/elasticsearch",
      "tag":"5.4.1",
      "size":"519 MB",
      "created":"2017-06-01 16:43:22 +0200 CEST"
   }
]

Container stats

dockercmd.stats(container_id).then(result => {
    console.log(result);
});

Return exemple :

{
   "container_id":"734121f89a41",
   "cpu_perc":"0.04%",
   "mem_usage":{
      "used":"12.15 MiB",
      "limit":"15.56 GiB"
   },
   "mem_perc":"0.08%",
   "net_io":{
      "in":"0 B",
      "out":"0 B"
   },
   "block_io":{
      "in":"0 B",
      "out":"90.1 kB"
   }
}

Start container

dockercmd.start(container_id).then(result => {
    console.log(result);
});

Stop container

dockercmd.stop(container_id).then(result => {
    console.log(result);
});

Remove container

dockercmd.rm(container_id).then(result => {
    console.log(result);
});

Remove image

dockercmd.rmi(image_id).then(result => {
    console.log(result);
});

License

MIT license.