docker-machine
Programmatic API to Docker Machine (0.6.0+).
example
node example.js ls /
const Machine = require('docker-machine')
const cmd = process.argv.slice(2)
if (!cmd.length) {
throw new TypeError('Requires a command to run')
}
const machine = new Machine
machine.start(function (err) {
if (err) throw err
machine.ssh(cmd, (err, result) => {
if (err) throw err
console.log(result)
})
})
new Machine([name || opts])
Options:
- name: defaults to
DOCKER_MACHINE_NAME
or "default"
machine.status((err, status) => ..)
Get lowercased status of machine.
machine.isRunning((err, running) => ..)
True if status is running
.
machine.start(err => ..)
Start machine, if not already running.
machine.env([opts], (err, result) => ..)
Options:
- json: if true, result will be an object
- shell: custom shell. Ignored if
json
is true.
machine.ssh(command, (err, result) => ..)
Run a command via SSH.
install
With npm do:
npm install docker-machine
license
MIT © Vincent Weevers