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

dockers-ps

v1.0.0

Published

Get a list of containers running on multiple docker hosts

Downloads

6

Readme

dockers-ps

get a list of containers that are running across multiple docker hosts

install

$ npm install dockers-ps

usage

var dockersps = require('dockers-ps')

var servers = [{
	hostname:'node1',
	docker:'192.168.8.120:2375'
},{
	hostname:'node2',
	docker:'192.168.8.121:2375'
},{
	hostname:'node3',
	docker:'192.168.8.122:2375'
}]

// create a cluster by passing a function that will list our inventory of servers
var cluster = dockersps(function(done){
	done(null, servers)	
})

// get a list of containers running across all servers
cluster.ps(function(err, containers){
	// an extra name exists for each container - name@hostname	
})

// find what server a certain job is running on
cluster.search('jobname', function(err, server){
	// server is null if no job was found	
})

api

var cluster = dockersps(inventoryfn)

Create a cluster by passing a function that will list our inventory.

The function has a signature of function(done){}

You call the done callback with an array of objects one per server.

Each server object has 2 important keys:

  • hostname - the hostname
  • docker - the IP:PORT of the docker server running on the host

cluster.ps(function(err, list, collection){})

Get an array of all containers running across the cluster

Each container has an extra name which is the original name of the container + '@hostname'

So - if we have a container named test running on host3 - its extra name (as well as just 'test') would be:

test@host3

If the container has no name - the id will be used instead.

collection is an object that has the following keys:

  • names
  • shortids
  • ids

The keys of these objects are the names and ids of containers and the values are the hostnames of the server they are running on

There is another key of the collection:

  • servers

this maps the server hostname onto an array of containers running on that server

cluster.find(id, function(err, server){})

Find which server a container is running on - id can either be the container name or its id.

The server returned is the object from the inventory

license

MIT