Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting pre-hook for docker-compose file

I am running a dockerized django app and I am looking for a way to run (a) directive(s) every time before I build a docker container. More concretely, I would like to run docker-compose -f production.yml run --rm django python manage.py check --deploy each time before I either build or up the production.yml file and stop the build process if any erroroccur. Like a pre-hook.

I know I could achieve this with a bash-script, yet I was wondering if there is a way of doing this inside the docker-compose file. I can't find anything in the docker documentation (except events, but I don't understand if they serve for what I want to achieve) about it and I assume that this is not possible. Yet, maybe it is in fact possible or maybe there is a hacky workaround?

Thanks in advance for any tips.

like image 962
Micromegas Avatar asked Feb 26 '26 09:02

Micromegas


1 Answers

Currently, this is not possible. There have been multiple requests to add such functionality, but the maintainers do not consider this a good idea.

See:

  • https://github.com/docker/compose/issues/468
  • https://github.com/docker/compose/issues/1341
  • https://github.com/docker/compose/issues/6736
like image 86
istepaniuk Avatar answered Feb 28 '26 23:02

istepaniuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!