Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mcollina/docker-allcontainers

Get notified when a new container is started or stopped
https://github.com/mcollina/docker-allcontainers

Last synced: about 2 months ago
JSON representation

Get notified when a new container is started or stopped

Awesome Lists containing this project

README

        

# docker-allcontainers

Get notified when a new container is started or stopped

## Install

```bash
npm install docker-allcontainers --save
```

## Usage

```js
var allContainer = require('docker-allcontainers')
var ee = allContainers({
preheat: true, // emit starts event for all already running containers
docker: null, // options to Dockerode
matchByName: /hello/, // optional
matchByImage: /matteocollina/, //optional
skipByName: /.*pasteur.*/, //optional
skipByImage: /.*dockerfile.*/ //optional
})
ee.on('start', function(meta, container) {
// container is a Dockerode Container
// see Dockerode API
console.log('started', meta)
})
ee.on('stop', function(meta, container) {
// container is a Dockerode Container
// see Dockerode API
console.log('stopped', meta)
})

// stop after 5 secs
setTimeout(function() {
ee.destroy()
}, 5000)
```

## License

MIT