简体   繁体   English

为 docker-compose 文件设置预挂钩

[英]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.我正在运行一个 dockerized django 应用程序,我正在寻找一种在构建 docker 容器之前每次运行(a)指令的方法。 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.更具体地说,我想在每次构建或启动 production.yml 文件之前docker-compose -f production.yml run --rm django python manage.py check --deploy并在发生任何错误时停止构建过程. 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.我知道我可以用 bash 脚本来实现这一点,但我想知道是否有办法在 docker-compose 文件中做到这一点。 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.我在 docker 文档中找不到任何关于它的内容(事件除外,但我不明白它们是否为我想要实现的目标服务),我认为这是不可能的。 Yet, maybe it is in fact possible or maybe there is a hacky workaround?然而,也许这实际上是可能的,或者也许有一个hacky的解决方法?

Thanks in advance for any tips.提前感谢您的任何提示。

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:看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM