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-links

v1.0.2

Published

A helper for parsing Docker link environment variables.

Downloads

10

Readme

Docker Links Environment Parser

Docker has a feature where you can link containers together by name. For example, you start a redis-server in a docker container and expose the default redis port 6379:

$ docker run -p 6379 -d -name redis vagrant/redis-server

You then start another containiner running a node.js web service that needs to access this redis server:

$ docker run --link redis:db -d vagrant/nodejs

Docker will internally hook up these the two containers and pass host and port information to the node.js web service via environment variables:

DB_NAME=/romantic_lumiere/db
DB_PORT=tcp://172.17.0.5:6379
DB_PORT_6379_TCP=tcp://172.17.0.5:6379
DB_PORT_6379_TCP_ADDR=172.17.0.5
DB_PORT_6379_TCP_PORT=6379
DB_PORT_6379_TCP_PROTO=tcp

This library provides a helper parseLinks that will parse these environment variables into easily navigable Javascript objects.

Install

Install docker-links via npm

$ npm install docker-links

Example Usage

Consider a container that accesses three external services on two other containers. The first container exposes redis on port 6379 and postgres on 6500. The second container exposes redis on port 6379.

DB_NAME=/romantic_lumiere/db
DB_PORT=tcp://172.17.0.5:6379
DB_PORT_6379_TCP=tcp://172.17.0.5:6379
DB_PORT_6379_TCP_ADDR=172.17.0.5
DB_PORT_6379_TCP_PORT=6379
DB_PORT_6379_TCP_PROTO=tcp
DB_PORT_6500_TCP=tcp://172.17.0.5:6500
DB_PORT_6500_TCP_ADDR=172.17.0.5
DB_PORT_6500_TCP_PORT=6500
DB_PORT_6500_TCP_PROTO=tcp
DB_REDIS_NAME=/romantic_lumiere/db_redis
DB_REDIS_PORT=tcp://172.17.0.2:6379
DB_REDIS_PORT_6379_TCP=tcp://172.17.0.2:6379
DB_REDIS_PORT_6379_TCP_ADDR=172.17.0.2
DB_REDIS_PORT_6379_TCP_PORT=6379
DB_REDIS_PORT_6379_TCP_PROTO=tcp

Parse with docker-links:

var links = require('docker-links').parseLinks(process.env);

Links is then the following object:

{
  "db": {
    "port": 6379,
    "hostname": "172.17.0.5",
    "url": "tcp://172.17.0.5:6379",
    "proto": "tcp",
    "name": "romantic_lumiere/db",
    "tcp": {
      "6379": {
        "hostname": "172.17.0.5",
        "url": "tcp://172.17.0.5:6379"
      },
      "6500": {
        "hostname": "172.17.0.5",
        "url": "tcp://172.17.0.5:6500"
      }
    }
  },
  "db_redis": {
    "port": 6379,
    "hostname": "172.17.0.2",
    "url": "tcp://172.17.0.2:6379",
    "proto": "tcp",
    "name": "romantic_lumiere/db_redis",
    "tcp": {
      "6379": {
        "hostname": "172.17.0.2",
        "url": "tcp://172.17.0.2:6379"
      }
    }
  }
}