如何控制 docker-compose 构建顺序? [英] How to control docker-compose build order?
问题描述
我要构建三个服务,A、B 和 C.首先应该构建 A,因为 B 和 C 依赖于 A(它们将 A 作为映像导入).我认为它们应该按顺序构建,但我发现它们是按某种随机顺序构建的?
I have three services to build, A、B and C. A should be built in the very first place, because B and C depend on A (they import A as image). I thought they should be built in order but I just find out they are built in some random order?
那么,如何在 docker-compose.yml
中控制构建顺序?
So, how do I control build order in docker-compose.yml
?
推荐答案
更新:在最近的实践中,我发现我的答案仅与运行排序有关.
参考 Quinten Scheppermans 的回答和 Authur Weborg 关于 dobi 的评论.
Update: In recent practice, I have found my answer to only pertain to run ordering.
Refer to the answer by Quinten Scheppermans and the comment by Authur Weborg about dobi.
您可以使用 depends_on
指令.
You can control build order using depends_on
directive.
services:
...
B:
depends_on:
- A
C:
depends_on:
- A
这篇关于如何控制 docker-compose 构建顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!