Sign inSign up

uip9av6y/container-notify

By uip9av6y

•Updated over 8 years ago

Signal docker containers upon filesystem changes.

Image
1

341

uip9av6y/container-notify repository overview

⁠container-notify

Signal docker containers upon filesystem changes. Reacts to changes in the filesystem either via kernel events or by polling in regular intervals. Containers can either be restarted or sent a signal. Suitable for deployment with docker-compose or just docker.

Simply said, this project acts as glue between the filesystem (using the Listen⁠ Gem) and Docker (using the Docker⁠-API Gem)

Containers will be queried with every change. Containers started after the monitor will still be notified if they satisfy the query criteria.

⁠Usage

Instructions can either be given via commandline arguments or environment variables.

docker run -d --name my-container-notify --mount type=volume,source=examples,destination=/watch --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock --env NOTIFY_LATENCY=60 container-notify:latest --watch=/watch

OptionTypeDescriptionDefault Value
-f, --filter PATTERNRegexReact only to file changes matching the given patternAll files trigger notifications, exceptions apply *
-a, --action ACTIONStringSignal/Action to performHUP
-d, --delay SECONDSFloatTime to wait before dispatching notifications**
-l, --latency SECONDSFloatTime between checking for changes**
-v, --[no-]verboseBoolChange verbosity for reports about state changes and performed actions-
-c, --compose [PROJECT]StringNotify containers based on the docker-compose service label value instead of their nameThe same project as the container ***
-p, --[no-]pollingPoll filesystem for changes instead of listening to eventsBool-
-N, --notify CONTAINERStringContainer (name) to notify upon changesAll containers sharing the same mounts as the current container
-W, --watch TARGETDirectoryMount (directory) to watch for changesAll mounts of the current container

* The Listen⁠ ignores certain files automatically, such as VCS metadata

** Uses the Listen⁠ default values, which are different if polling is enabled

*** Using '.' will reduce the search to containers of the same compose project, using '*', will search for every container with the com.docker.compose.service label.

Environment variableCommandline equivalent
NOTIFY_DELAY-d
NOTIFY_LATENCY-l
CONTAINER_ACTION-a
MOUNT_FILE_FILTER-f
COMPOSE_PROJECT-c
FORCE_POLLING *-p
LOG_VERBOSITY-v

* The mere existence of this variable results in the activation of this behaviour

⁠Image setup

the image is based on the Alpine Linux image from the Docker library⁠.

⁠Development

Docker-Compose is used to create an encapsulated development environment. After checking out the repo, run docker-compose run --rm monitor sh to enter the container. Then, run bundle exec rake spec to run the tests. The main application can be run with ./bin/container-notify.

The source code from the host is mounted into the container and any change is reflected immediately; you most likely need to stop the application if running (Ctrl+C) and start it again.

⁠Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/uip9av6y/container-notify⁠.

⁠License

The gem is available as open source under the terms of the MIT License⁠.

The Docker image also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained). It is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Tag summary

Content type

Image

Digest

Size

21.8 MB

Last updated

over 8 years ago

docker pull uip9av6y/container-notify