ONBUILD部分的占位符字段用于子码头坞图像使用 [英] Placeholder field for the ONBUILD section for child docker images to use
问题描述
从ubuntu
ONBUILD ADD package .json / project /
ONBUILD RUN //做一些东西
ONBUILD ADD。 / project
问题是我有几个孩子图像有不同的文件夹名称(而不是项目 )。另外,其中一个有多个项目文件夹。
所以当我在子图像中使用它时,我不能在执行ONBUILD之前创建该文件夹。这是有道理的,因为构建应属于基础图像。但是有没有办法推迟呢?另外,文件夹的名称可以是一个占位符,所以我将其替换为子图像。或者在这种情况下可能不适合使用ONBUILD?
非常感谢提前
我刚刚遇到这个确切的问题,从文档中可以看出,它似乎没有办法推迟 onbuild
stanzas连锁码头Dockerfiles,目前。它只会执行到其子Dockerfile。
从文档中:
执行后,触发器从最终的图像中清除。换句话说,它们不被大孩子的构建继承。
我倾向于建立一个边缘 '基本图像继承自基本图像,并且只添加必要的 onbuild
节。基本图像本身不会包含任何生成行。
We have several child projects which use base Image. The code looks like this.
From ubuntu
ONBUILD ADD package.json /project/
ONBUILD RUN //do some stuff
ONBUILD ADD . /project
The issue is that I have several child images which has different folder name (not "project"). Also, one of them has multiple project folders.
so when I use it in child image, I cant create the folder before ONBUILD executed. which makes sense and since the build should belong to base image. but is there a way I can defer it. Also, is the folder name can be a placeholder, so I will replace it in the child images. Or it may not be suitable to use ONBUILD in this scenario ?
Many thanks in advance
I just ran into this exact issue, and judging from the docs, it doesn't look like there's a way to defer onbuild
stanzas further down the chain of descendant Dockerfiles, currently. It only defers execution to its child Dockerfile.
From the docs:
Triggers are cleared from the final image after being executed. In other words they are not inherited by "grand-children" builds.
One solution I'm inclined towards is to build 'edge' base images which inherit from a base image, and only add the necessary onbuild
stanzas. The base images themselves would not contain any onbuild lines.
这篇关于ONBUILD部分的占位符字段用于子码头坞图像使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!