compose icon indicating copy to clipboard operation
compose copied to clipboard

Proposal: docker-compose events

Open dnephin opened this issue 11 years ago • 68 comments

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

dnephin avatar Jun 04 '15 15:06 dnephin

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?

thaJeztah avatar Jun 04 '15 16:06 thaJeztah

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.

dnephin avatar Jun 04 '15 16:06 dnephin

Ah, yes. Makes sense. Count me interested :)

thaJeztah avatar Jun 04 '15 17:06 thaJeztah

+1

arioch avatar Jul 15 '15 11:07 arioch

+1

Ozzyboshi avatar Jul 23 '15 19:07 Ozzyboshi

yeah actually, I prefer this concept to plain "allow to run scripts 'before/ after' nonsense" +1

hodonsky avatar Jul 27 '15 19:07 hodonsky

Example usage: OnExit (of my web server in a Docker container) run a script to close port 80 on the firewall.

Harrison-Uhl avatar Aug 06 '15 20:08 Harrison-Uhl

I started to look into this, but I think to do it properly the docker remote api needs to support filtering by labels.

dnephin avatar Aug 31 '15 18:08 dnephin

@dnephin with filtering, you mean filtering events based on labels?

thaJeztah avatar Aug 31 '15 18:08 thaJeztah

@thaJeztah Exactly, https://docs.docker.com/reference/commandline/events/ only supports filtering by image id, container id, or event type

dnephin avatar Aug 31 '15 18:08 dnephin

@dnephin feature requests are welcome :+1: sounds like a nice feature to work on for contributors as well (clear goal)

thaJeztah avatar Aug 31 '15 18:08 thaJeztah

Really in need of this feature +1

LiberQuack avatar Oct 31 '15 04:10 LiberQuack

:+1:

mgcrea avatar Nov 01 '15 23:11 mgcrea

:+1:

bbtfr avatar Nov 05 '15 05:11 bbtfr

+1

Lohhari avatar Nov 12 '15 18:11 Lohhari

+1

kumavis avatar Nov 18 '15 22:11 kumavis

+1

rriemann avatar Nov 22 '15 16:11 rriemann

+1

leostera avatar Nov 23 '15 07:11 leostera

:+1:

majidgolshadi avatar Nov 24 '15 07:11 majidgolshadi

:+1:

dmouse avatar Nov 25 '15 02:11 dmouse