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

v2.0.0

Published

Manage docker containers as services

Downloads

1

Readme

Docker Service Manager

Build Status

This tool allows the user to manage services run within docker containers. I created this tool out of the neccesity to have a multitude of services running on a single private server. These services might at times depend on each other and each expose different ports.

After messing around with virtual machines for quite some time, I finally settled on running each service in its own docker container. This application helps me (and maybe you), to easily mount folders and config files, to expose neccessary ports and to build and start all neccessary images and containers.

It also takes care of setting the containers timezone, so no time mismatches happen between the service and the host.

Structure of a Service

Each service lives inside its own folder. This folder may be located anywhere, and will be symlinked into /etc/docker-services by using

$ docker-service add /some/services/folder

This folder will not be deleted upon uninstalling this module, so you should take care of this on your own!

service.json

A service contains at its heart a service.json file, which may look like this:

{
	"tag": "paulavery/ympd",
	"name": "ympd",
	"ports": [
		8000
	],
	"mounts": {
		"music": "/etc/mopidy/music"
	},
	"deps": [
		"mpd"
	]
}

All its attributes are optional with the exception of a tag which we require.

tag

If a local Dockerfile is found, a new image will be built from it, under this tag. Otherwise, the tag will be pulled from the docker registry.

name

A name to later be used as the services container name. You will use this to reference services (start or stop them as well as have other services depend on them).

If omitted it will default to the part behind the / of your tag. I would suggest to use this property to allow for drop-in replacements of dependencies (e.g. a mopidy and an mpd service could both have different tags but the name mpd, as they are providing the same service for dependents).

ports

An array defining the ports this service will expose to you. This should not contain any ports not exposed to the user.

mounts

Define names for any directories which need to be mounted into your services container. See about the mounts directory below.

deps

An array listing all dependencies of this service. These dependencies will be started before loading up your service.

mounts directory

You should symlink your mounts here under the name defined in your service.json. This allows you to check in the required mounts to git, while easily assigning them on each machine. If you have no mounts, you do not need this directory.

config directory

This directory contains any configuration files for your service. These are linked into the services container, so you may change them without much fuss. You should treat this directory like a linux systems root folder. So config/etc/something.conf will be linked to /etc/something.conf inside the container. If you have no configuration files, you may omit this folder.

In addition, you may specify entire folders in your service.json's configs property. The following would mount config/home/sabnzbd/.sabnzbd and config/home/sabnzbd/downloads to /home/sabnzbd/.sabnzbd and /home/sabnzbd/downloads respectively:

{
	configs: {
		'home/sabnzbd': {
			'.sabnzbd': {},
			'downloads': {}
		}
	}
}

Single files will still be mounted seperately unless they are positioned in a folder which will be mounted.

CLI

The application exposes the following commands:

docker-service add <path>

Adds a new service from a directory

docker-service remove <name>

Removes the given service, including any images and containers.

docker-service start <name>

Builds any neccessary images and containers as well as starting all dependencies before starting up your service. First time doing this might take some time.

A -d/--nodaemon flag may be passed, to start a service in non-daemon mode.

docker-service stop <name>

Stops the container running your service

docker-service restart <name>

Restarts a service.

docker-service status <name>

Prints status information as json to the command line.

docker-service list

Lists all installed services with their current status.

docker-service systemd

Install a systemd service dockers to start services on boot. If the service is installed, removes it.

Use like:

systemctl enable dockers@servicename

Errors

This application does NOT print user-friendly error messages. If anything goes wrong (e.g. a dependency is missing), it just throws an error and crashes. The error messages should be self-explanatory though.