UNPKG

601 BJavaScriptView Raw
1'use strict'
2
3const Docker = require('node-docker-api').Docker
4
5const 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
11const docker = new Docker({ socketPath: '/var/run/docker.sock' })
12
13return 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))