1.0.1 • Published 5 years ago

docker-starter v1.0.1

Weekly downloads
10
License
ISC
Repository
github
Last release
5 years ago

Docker Starter

A simple npm module that allows you to start and stop docker containers from node, using shelljs to pass docker commands to the command line.

Designed to work on Linux distributions, and Mac (Darwin).

Because this package works by passing commands to the unix command line - you must already have the docker client installed and on $PATH. i.e. if you can run docker ps on the command line - then you should be good to go.

Installation:

npm install docker-starter

Example:

const dockerStarter = require('docker-starter');

const mongo = dockerStarter({
  container: 'db-test',
  image: 'mongo:4.0.4',
  extraOptions: '--restart on-failure:5',
  containerPort: 27017,
  publishedPort: 27019,
});

const { host, port, wasAlreadyRunning } = mongo.ensureRunning();

// do some stuff requiring mongo

mongo.stopAndRemove();