node-docker-api
Advanced tools
Comparing version 1.1.12 to 1.1.13
{ | ||
"name": "node-docker-api", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"description": "Docker Remote API driver for node", | ||
@@ -11,3 +11,3 @@ "main": "./lib/docker", | ||
"gendoc": "typedoc --out docs src", | ||
"build": "./node_modules/typescript/bin/tsc -d --outDir lib" | ||
"build": "tsc --outDir lib" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -128,2 +128,3 @@ # docker-api | ||
``` js | ||
'use strict' | ||
const Docker = require('node-docker-api').Docker, | ||
@@ -168,6 +169,6 @@ fs = require('fs') | ||
``` js | ||
'use strict' | ||
const Docker = require('node-docker-api').Docker | ||
const promisifyStream = (stream) => new Promise((resolve, reject) => { | ||
console.log(stream); | ||
stream.on('data', (d) => console.log(d.toString())) | ||
@@ -179,2 +180,3 @@ stream.on('end', resolve) | ||
let docker = new Docker({ socketPath: '/var/run/docker.sock' }) | ||
let _container | ||
@@ -187,18 +189,15 @@ docker.container.create({ | ||
.then((container) => container.start()) | ||
.then((_container) => { | ||
container = _container | ||
.then((container) => { | ||
_container = container | ||
return container.exec.create({ | ||
Cmd: [ "top" ] | ||
AttachStdout: true, | ||
AttachStderr: true, | ||
Cmd: [ 'echo', 'test' ] | ||
}) | ||
}) | ||
.then((exec) => { | ||
return exec.start() | ||
return exec.start({ Detach: false }) | ||
}) | ||
.then((stream) => { | ||
stream.on('data', (info) => { | ||
console.log(info.toString()) | ||
_container.kill() | ||
}) | ||
stream.on('error', (err) => console.log(err)) | ||
}) | ||
.then((stream) => promisifyStream(stream)) | ||
.then(() => _container.kill()) | ||
.catch((error) => console.log(error)) | ||
@@ -226,3 +225,3 @@ ``` | ||
.then((stream) => promisifyStream(stream)) | ||
.then(() => docker.image.status('testimg')) | ||
.then(() => docker.image.get('testimg').status()) | ||
.then((image) => image.remove()) | ||
@@ -235,2 +234,4 @@ .catch((error) => console.log(error)) | ||
``` js | ||
'use strict' | ||
const Docker = require('node-docker-api').Docker | ||
@@ -248,3 +249,3 @@ | ||
.then((stream) => promisifyStream(stream)) | ||
.then(() => docker.image.status('ubuntu')) | ||
.then(() => docker.image.get('ubuntu').status()) | ||
.then((image) => image.history()) | ||
@@ -258,9 +259,11 @@ .then((events) => console.log(events)) | ||
``` js | ||
const Docker = require('node-docker-api').Docker, | ||
fs = require('fs') | ||
'use strict' | ||
const Docker = require('../lib/docker').Docker, | ||
fs = require('fs') | ||
const promisifyStream = (stream) => new Promise((resolve, reject) => { | ||
stream.on('data', (d) => console.log(data)) | ||
stream.on('end', resolve) | ||
stream.on('error', reject) | ||
stream.on('data', (d) => console.log(d.toString())) | ||
stream.on('end', resolve) | ||
stream.on('error', reject) | ||
}) | ||
@@ -271,7 +274,6 @@ | ||
docker.events({ | ||
since: ((new Date().getTime() / 1000) - 60).toFixed(0) | ||
since: ((new Date().getTime() / 1000) - 60).toFixed(0) | ||
}) | ||
.then((container) => container.events()) | ||
.then((stream) => promisifyStream(stream)) | ||
.catch((error) => console.log(error)) | ||
``` |
Sorry, the diff of this file is not supported yet
271
1396622