Proposal: docker-compose events
There have been a few requests for supporting some form of "hooks" system within compose (#74, #1341).
A feature which runs commands on the host would add a lot of complexity to compose and the compose configuration. Another option is to support these features by providing a way for external tools to run the command triggered by an event.
docker events provides an event stream of all docker events, but would still require filtering.
docker-compose events could provide a similar interface by filtering the events returned by /events and return a stream of only the events related to the active compose project. The event stream could also include a new field "service": <service_name> in addition to the fields already provided by /events
Hm fancy!
If accompanied by some clear examples, this would be a great feature.
Given that compose doesn't have a service/daemon. How would this work? (just wondering). Also; will subscribers listen to events for all projects, or receive only events for a specific project?
I think it should be just the specific project, otherwise it's not really more useful than the existing /events endpoint from docker engine.
Given that compose doesn't have a service/daemon. How would this work?
I think it would work similar to docker-compose logs. Streaming from the docker daemon, and filter out events that aren't related to the project. To consume the events you would pipe stdout to another application.
Ah, yes. Makes sense. Count me interested :)
+1
+1
yeah actually, I prefer this concept to plain "allow to run scripts 'before/ after' nonsense" +1
Example usage: OnExit (of my web server in a Docker container) run a script to close port 80 on the firewall.
I started to look into this, but I think to do it properly the docker remote api needs to support filtering by labels.
@dnephin with filtering, you mean filtering events based on labels?
@thaJeztah Exactly, https://docs.docker.com/reference/commandline/events/ only supports filtering by image id, container id, or event type
@dnephin feature requests are welcome :+1: sounds like a nice feature to work on for contributors as well (clear goal)
Really in need of this feature +1
:+1:
:+1:
+1
+1
+1
+1
:+1:
:+1: