A)在Dockerfile中,我给出了ONBUILD指令来做某事。然后,我构建此图像(将其命名为“parent_image”)
B)这样,当我构建使用第一个图像的另一个图像时,将调用此指令。生成的第二个图像是“child_image”。
C)如果我从child_image生成另一个图像(“grandchild_image”),则不会运行“parent_image”的ONBUILD指令。
有没有一种方法可以使“parent_image”的ONBUILD指令独立于其上构建的图像级别运行?
最佳答案
我知道这是一个古老的问题,但我也为此感到困惑,我在James Turnbull的“Docker书”中找到了以下解释:
The ONBUILD triggers are executed in the order specified in the parent image and are only inherited once. If we build another image from this new image, [..], then the triggers would not be executed when that image is built.
因此,对于将来寻找它的任何人来说,这都是不可能的。
关于docker - 在嵌套的已构建Docker镜像中ONBUILD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43765139/