New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Service lifecycle event hooks #5764

Closed
pedro93 opened this Issue Mar 8, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@pedro93

pedro93 commented Mar 8, 2018

I've been digging across the docker-compose documentation and found the following page regarding container event streaming.

My question is, given that it is possible to be alerted about a container hitting lifecycle stages (created, started, restarts, stops etc ...), full list here, it is possible with docker-compose to listen for such service events and perform an arbitrary script at each stage, such that, that hook pauses the docker-compose process?

As an example, let's say I have an orchestration between two services A, B where B depends on A being healthy. Additionally, service A needs to know some information about B which is dynamically generated on service bootup.

The solution I am looking is some form of before entry point on service B, halt the docker-compose up process so that I can, in the host retrieve the dynamic information from A, generate a bash script with that information, execute the script on service B and then proceed with the docker-compose process.

Thank you for maintaining this project, it is extremely useful :)

Edit: Updated last paragraph, mixed up the service order, my apologies

@shin-

This comment has been minimized.

Member

shin- commented Mar 8, 2018

See our recommendation here: #2392
And the wider discussion on this feature here: #1341

@shin- shin- added the kind/question label Mar 8, 2018

@pedro93

This comment has been minimized.

pedro93 commented Mar 8, 2018

Thank you, I have commented on the linked issue.

@shin-

This comment has been minimized.

Member

shin- commented Mar 8, 2018

Out of curiosity, why can't that provisioning be part of your entrypoint script?

@pedro93

This comment has been minimized.

pedro93 commented Mar 8, 2018

Because the entrypoint script is defined in the host and executed in the container (this case service B) but the information I would need to add to the entrypoint script is generated in the runtime of service A.

Does that make it clearer?

@shin-

This comment has been minimized.

Member

shin- commented Mar 8, 2018

It seems like B's entrypoint could make a request to A for that information. Not only would that work with the current tool, it would ensure that if B crashes and needs to restart, it's able to retrieve the information again without any intervention by the Compose process.

@pedro93

This comment has been minimized.

pedro93 commented Mar 8, 2018

Thank you @shin- for the assistance, I agree with you that that particular approach would work, but you are assuming one key thing, that the information from A is accessible from an endpoint. Unfortunatly this is not the case and it is not in my power to change it.

@pedro93

This comment has been minimized.

pedro93 commented Mar 8, 2018

About #2392 correct me if I am wrong but the event listening does not actually pause the docker-compose process right?

@shin-

This comment has been minimized.

Member

shin- commented Mar 8, 2018

I see. Sorry I couldn't be of help.

And no, docker-compose events doesn't pause the process.

@pedro93

This comment has been minimized.

pedro93 commented Mar 8, 2018

Thank you regardless 😄 you may close the issue. I will have to find some other tool for my particular needs.

+1 on the project.

@shin- shin- closed this Mar 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment