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

@clusterworks/cdocker

v1.0.2

Published

Run commands across a cluster of Docker Engines

Downloads

4

Readme

cdocker

An easy way to run commands across a cluster of Docker Engines without needing a Swarm.

Example

cdocker run -d -e "constraint:node==enode{1..10}" --name "nginx_{1..10}" -p 80:80 nginx

It looks like a regular Docker run command but with a few smart additions:

  • Prefix your command with cdocker instead of docker
  • Use classic Swarm mode constraints
  • Use brace expansion in constraint and name parameters to create arrays of containers

This command will create an array of 10 containers, 1 on each node, named nginx_1 on node enode1, nginx_2 on node enode2 and so on.

In addition to brace expansions, you can use globbing:

cdocker kill "nginx_*"

will kill containers on all nodes with names that match the nginx_* pattern.

You can narrow this down by specifying which nodes, again similar to how they are represented in classic Swarm:

cdocker kill "enode{1..5}/nginx_*"

will kill the matching containers only on enode1 to enode5.

Installation

It is written in Node.js, so install using npm:

sudo npm install -g cdocker

and add your nodes like so

cdocker node add 192.168.0.2

The default port we will try and find your Docker Engines on is 2375 but that can be changed with the --port option.

Of course, you can also use brace expansion here

cdocker node add "192.168.0.{11..20}"

When you add or remove nodes, this list will be stored in the ~/.cdocker.json file.

Scheduling

Scheduling arrays of containers to nodes is achieved by first finding nodes that match the specified constraints.

At the moment we only support name and label constraints

Then, one of 3 situations will be reached:

  • There are less nodes matched than there are containers you want to start (nodes < containers)
  • There are exactly the same number of nodes to containers you want to start (nodes == containers)
  • There are more nodes matched than there are containers you want to start (nodes > containers)

Less nodes than containers you want to start

In this instance, cdocker will use a round robin strategy to distribute the containers among the matched nodes.

For example, if you want to start 10 containers on 5 nodes, each node will have 2 containers on it.

Exactly the same number of nodes as containers you want to start

In this instance, cdocker will create a straight up mapping of 1 container to 1 node.

More nodes than containers you want to start

In this instance, you can decide between different strategies on how to utilise the available nodes that matched your constraints.

  • unique-random will schedule the containers to random nodes, never using the same node twice
  • least-running will order the nodes based on how many containers are already running on them and use those that are the least loaded

You can specify the strategy in the run command as an environment variable, just like the constraints:

-e strategy:unique-random

If you don't specify a strategy, least-running will be used by default. However, this requires enumeration of all matched nodes which may degrade performance on very large clusters.