1 | 'use strict'
|
2 |
|
3 | const Docker = require('node-docker-api').Docker
|
4 |
|
5 | const promisifyStream = (stream) => new Promise((resolve, reject) => {
|
6 | stream.on('data', (d) => console.log(d.toString()))
|
7 | stream.on('end', resolve)
|
8 | stream.on('error', reject)
|
9 | })
|
10 |
|
11 | const docker = new Docker({ socketPath: '/var/run/docker.sock' })
|
12 |
|
13 | return docker.image.create({}, { fromImage: 'ubuntu', tag: 'latest' })
|
14 | .then((stream) => promisifyStream(stream))
|
15 | .then(() => docker.image.get('ubuntu').status())
|
16 | .then((image) => image.history())
|
17 | .then((events) => console.log(events))
|
18 | .catch((error) => console.log(error))
|