https://github.com/comsave/docker-swarm-watcher
Listens docker service create & remove events and executes custom command
https://github.com/comsave/docker-swarm-watcher
Last synced: 2 months ago
JSON representation
Listens docker service create & remove events and executes custom command
- Host: GitHub
- URL: https://github.com/comsave/docker-swarm-watcher
- Owner: comsave
- License: mit
- Created: 2018-06-20T09:11:47.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-07T12:18:07.000Z (about 6 years ago)
- Last Synced: 2025-04-06T10:42:55.028Z (12 months ago)
- Language: Go
- Homepage:
- Size: 3.38 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-swarm-watcher
Listen for docker swarm events and exposes and event endpoint.
# Requirements
Only swarm managers can retrieve swarm events. If you're not receiving all events selinux might be the cause.
```yml
version: "3"
services:
web:
deploy:
placement:
constraints: [node.role == manager]
```
# build / install
- `go get -d -v ./...`
- `go build ./...`
- `go install -v ./...`
# run
To expose an event endpoint and listen to docker service:create events
```bash
docker-swarm-watcher -c="/bin/echo hello" -u username -p password -s="unix:///var/run/docker.sock" -e="service:create"
```
To specify specific commands for each event you can use a command file. See example-commands.yml
```bash
docker-swarm-watcher -u username -p password -s="unix:///var/run/docker.sock" -f="/home/user/commands.yml"
```
Custom events can be send to http://localhost:8888/v1/event/new
# options
| Name | Flag | Description
|---|---|---|
| Command | -c | Command to execute when an event is fired |
| username | -u | Basic authentication username |
| password | -p | Basic authentication password |
| port | -port | Port to expose -- defaults to 8888 |
| socket | -s | Docker socket to poll -- e.g. unix:///var/run/docker.sock |
| events | -e | Comma separated list of Docker events to listen to |
| commandFile | -f | Commands yml file |
| maxEventAge | -max-event-age | Replay events if there age is less than x minutes |