npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

docker-machine

v3.0.1

Published

Programmatic API to Docker Machine

Downloads

40,570

Readme

docker-machine

Programmatic API to Docker Machine (0.6.0+).
Wraps the docker-machine CLI.

node npm status Travis build status AppVeyor build status Dependency status JavaScript Style Guide

Table of Contents

Example

node example.js ls /

const Machine = require('docker-machine')
const cmd = process.argv.slice(2)
const machine = new Machine()

// Start if not already started
machine.start(function (err) {
  if (err) throw err

  // Execute a command
  machine.ssh(cmd, (err, result) => {
    if (err) throw err
    console.log(result)
  })
})

API

new Machine([name || opts])

Options:

  • name: defaults to DOCKER_MACHINE_NAME or "default"

machine.status((err, status) => ..)

Get lowercased status of the machine.

machine.isRunning((err, running) => ..)

True if status is running.

machine.start(err => ..)

Start machine, if not already running.

machine.stop(err => ..)

Stop machine, if not already stopped.

machine.kill(err => ..)

Kill machine, if not already stopped.

machine.env([opts], (err, result) => ..)

Get the environment variables to dictate that Docker should run a command against a particular machine. By default, env() returns the output from docker-machine env as-is. That is, a script which can be run in a subshell. Options:

  • shell: custom shell. Ignored if parse is true.
  • parse: if true, result will be a plain object:
{
  DOCKER_TLS_VERIFY: '1',
  DOCKER_HOST: 'tcp://<ip>:<port>',
  DOCKER_CERT_PATH: '<home>/.docker/machine/machines/<name>',
  DOCKER_MACHINE_NAME: '<name>'
}

machine.ssh(command, (err, result) => ..)

Run a command via SSH. The command can be a string or an array.

machine.inspect((err, result) => ..)

Get the output of docker-machine inspect as a plain object with camelCase properties.

Static methods

All of the above methods (from status() to inspect()) are also accessible as static methods, where the first argument is a name. For example:

const Machine = require('docker-machine')

Machine.env('default', { json: true }, (err, result) => {
  console.log(result.DOCKER_HOST)
})

Machine.create(name, driver[, options], (err) => ..)

Create a machine. Options are driver-specific.

const options = {
  'virtualbox-memory': '1024'
}

Machine.create('test', 'virtualbox', options, (err) => {
  if (err) throw err
})

Machine.list([opts], (err, machines) => ..)

Get all machines as an array, via docker-machine ls. Each machine is a plain object with camelCase properties.

{
  name: 'agent-1',                  // Machine name
  activeHost: false,                // Is the machine an active host?
  activeSwarm: false,               // Is the machine an active swarm master?
  active: '*',                      // Human-readable combination of the above
  driverName: 'virtualbox',         // Driver name
  state: 'running',                 // Machine state (running, stopped)
  url: 'tcp://192.168.99.101:2376', // Machine URL
  swarm: null,                      // Machine swarm name
  dockerVersion: 'v1.12.0',         // Docker Daemon version
  responseTime: 980,                // Time taken by the host to respond (ms)
  error: null                       // Machine errors
}

Options:

  • timeout: ls timeout in seconds (see docker/machine#1696)
  • inspect: if true, also include the metadata from inspect() for each machine:
{
  name: 'agent-1',                  // Plus all of the above
  driver: {                         // Driver metadata
    cpu: 1,
    memory: 2048,
    hostOnlyCidr: '192.168.99.1/24',
    ..
  },
  hostOptions: {                    // Various host options
    engineOptions: ..
    swarmOptions: ..
  }
}

Install

With npm do:

npm install docker-machine

License

MIT © 2016-present Vincent Weevers