Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-docker-api

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-docker-api - npm Package Compare versions

Comparing version 1.1.16 to 1.1.17

2

examples/list_containers.js

@@ -11,5 +11,5 @@ const Docker = require('node-docker-api').Docker

.then((stats) => {
stats.on('data', (stat) => console.log('Stats: ',stat))
stats.on('data', (stat) => console.log('Stats: ', stat.toString()))
stats.on('error', (err) => console.log('Error: ', err))
})
.catch((error) => console.log(error))
{
"name": "node-docker-api",
"version": "1.1.16",
"version": "1.1.17",
"description": "Docker Remote API driver for node",

@@ -5,0 +5,0 @@ "main": "./lib/docker",

@@ -21,5 +21,6 @@ # docker-api

## Installation
```console
$ npm install node-docker-api
```
`npm install node-docker-api`
## Usage

@@ -32,5 +33,6 @@

``` js
const Docker = require('node-docker-api').Docker
'use strict';
const {Docker} = require('node-docker-api');
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

@@ -41,7 +43,7 @@ docker.container.create({

})
.then((container) => container.start())
.then((container) => container.stop())
.then((container) => container.restart())
.then((container) => container.delete({ force: true }))
.catch((error) => console.log(error))
.then(container => container.start())
.then(container => container.stop())
.then(container => container.restart())
.then(container => container.delete({ force: true }))
.catch(error => console.log(error));
```

@@ -52,5 +54,6 @@

``` js
const Docker = require('node-docker-api').Docker
'use strict';
const {Docker} = require('node-docker-api');
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

@@ -60,6 +63,6 @@ // List

// Inspect
.then((containers) => containers[0].status())
.then((container) => container.top())
.then((processes) => console.log(processes))
.catch((error) => console.log(error))
.then(containers => containers[0].status())
.then(container => container.top())
.then(processes => console.log(processes))
.catch(error => console.log(error));
```

@@ -70,5 +73,6 @@

``` js
const Docker = require('node-docker-api').Docker
'use strict';
const {Docker} = require('node-docker-api');
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

@@ -78,9 +82,9 @@ // List

// Inspect
.then((containers) => containers[0].status())
.then((container) => container.stats())
.then((stats) => {
stats.on('data', (stat) => console.log('Stats: ', stat.toString()))
stats.on('error', (err) => console.log('Error: ', err))
.then(containers => containers[0].status())
.then(container => container.stats())
.then(stats => {
stats.on('data', stat => console.log('Stats: ', stat.toString()))
stats.on('error', err => console.log('Error: ', err))
})
.catch((error) => console.log(error))
.catch(error => console.log(error));
```

@@ -91,6 +95,7 @@

```js
const Docker = require('node-docker-api').Docker
'use strict';
const {Docker} = require('node-docker-api');
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
let container
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
let container;

@@ -101,3 +106,3 @@ docker.container.create({

})
.then((container) => container.logs({
.then(container => container.logs({
follow: true,

@@ -107,7 +112,7 @@ stdout: true,

}))
.then((stream) => {
stream.on('data', (info) => console.log(info))
stream.on('error', (err) => console.log(err))
.then(stream => {
stream.on('data', info => console.log(info))
stream.on('error', err => console.log(err))
})
.catch((error) => console.log(error))
.catch(error => console.log(error));
```

@@ -118,7 +123,7 @@

``` js
const Docker = require('node-docker-api').Docker,
fs = require('fs')
const {Docker} = require('node-docker-api');
const fs = require('fs');
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
let container
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
let container;

@@ -129,9 +134,9 @@ docker.container.create({

})
.then((container) => container.start())
.then((container) => container.export())
.then((content) => {
.then(container => container.start())
.then(container => container.export())
.then(content => {
const file = fs.createWriteStream("container.tar");
file.end(content)
})
.catch((error) => console.log(error))
.catch(error => console.log(error));
```

@@ -142,14 +147,14 @@

``` js
'use strict'
const Docker = require('node-docker-api').Docker,
fs = require('fs')
'use strict';
const fs = require('fs');
const {Docker} = require('node-docker-api');
const promisifyStream = (stream) => new Promise((resolve, reject) => {
stream.on('data', (d) => console.log(d.toString()))
const promisifyStream = stream => new Promise((resolve, reject) => {
stream.on('data', data => console.log(data.toString()))
stream.on('end', resolve)
stream.on('error', reject)
})
});
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
let container
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
let container;

@@ -161,4 +166,4 @@ docker.container.create({

})
.then((container) => container.start())
.then((_container) => {
.then(container => container.start())
.then(_container => {
container = _container

@@ -169,12 +174,12 @@ return _container.fs.put('./file.tar', {

})
.then((stream) => promisifyStream(stream))
.then(stream => promisifyStream(stream))
.then(() => container.fs.get({ path: '/var/log/dmesg' }))
.then((stream) => {
.then(stream => {
const file = fs.createWriteStream("file.jpg");
stream.pipe(file)
return promisifyStream(stream)
stream.pipe(file);
return promisifyStream(stream);
})
.then(() => container.status())
.then((container) => container.stop())
.catch((error) => console.log(error))
.then(container => container.stop())
.catch(error => console.log(error));
```

@@ -185,13 +190,13 @@

``` js
'use strict'
const Docker = require('node-docker-api').Docker
'use strict';
const {Docker} = require('node-docker-api');
const promisifyStream = (stream) => new Promise((resolve, reject) => {
stream.on('data', (d) => console.log(d.toString()))
const promisifyStream = stream => new Promise((resolve, reject) => {
stream.on('data', data => console.log(data.toString()))
stream.on('end', resolve)
stream.on('error', reject)
})
});
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
let _container
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
let _container;

@@ -203,4 +208,4 @@ docker.container.create({

})
.then((container) => container.start())
.then((container) => {
.then(container => container.start())
.then(container => {
_container = container

@@ -213,8 +218,8 @@ return container.exec.create({

})
.then((exec) => {
.then(exec => {
return exec.start({ Detach: false })
})
.then((stream) => promisifyStream(stream))
.then(stream => promisifyStream(stream))
.then(() => _container.kill())
.catch((error) => console.log(error))
.catch(error => console.log(error));
```

@@ -225,12 +230,13 @@

``` js
const Docker = require('node-docker-api').Docker,
tar = require('tar-fs')
'use strict';
const {Docker} = require('node-docker-api');
const tar = require('tar-fs');
const promisifyStream = (stream) => new Promise((resolve, reject) => {
stream.on('data', (d) => console.log(d.toString()))
const promisifyStream = stream => new Promise((resolve, reject) => {
stream.on('data', data => console.log(data.toString()))
stream.on('end', resolve)
stream.on('error', reject)
})
});
const docker = new Docker({ socketPath: '/var/run/docker.sock' })
const docker = new Docker({ socketPath: '/var/run/docker.sock' });

@@ -241,6 +247,6 @@ var tarStream = tar.pack('/path/to/Dockerfile')

})
.then((stream) => promisifyStream(stream))
.then(stream => promisifyStream(stream))
.then(() => docker.image.get('testimg').status())
.then((image) => image.remove())
.catch((error) => console.log(error))
.then(image => image.remove())
.catch(error => console.log(error));
```

@@ -251,6 +257,5 @@

``` js
'use strict'
'use strict';
const {Docker} = require('node-docker-api');
const Docker = require('node-docker-api').Docker
const promisifyStream = (stream) => new Promise((resolve, reject) => {

@@ -265,7 +270,7 @@ stream.on('data', (d) => console.log(d.toString()))

return docker.image.create({}, { fromImage: 'ubuntu', tag: 'latest' })
.then((stream) => promisifyStream(stream))
.then(stream => promisifyStream(stream))
.then(() => docker.image.get('ubuntu').status())
.then((image) => image.history())
.then((events) => console.log(events))
.catch((error) => console.log(error))
.then(image => image.history())
.then(events => console.log(events))
.catch(error => console.log(error))
```

@@ -277,8 +282,7 @@

'use strict'
const fs = require('fs');
const {Docker} = require('node-docker-api');
const Docker = require('node-docker-api').Docker,
fs = require('fs')
const promisifyStream = (stream) => new Promise((resolve, reject) => {
stream.on('data', (d) => console.log(d.toString()))
const promisifyStream = stream => new Promise((resolve, reject) => {
stream.on('data', data => console.log(data.toString()))
stream.on('end', resolve)

@@ -293,4 +297,4 @@ stream.on('error', reject)

})
.then((stream) => promisifyStream(stream))
.catch((error) => console.log(error))
.then(stream => promisifyStream(stream))
.catch(error => console.log(error))
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc