Placeholder field for the ONBUILD section for chil

2019-08-08 06:07发布

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

标签: docker
1条回答
叼着烟拽天下
2楼-- · 2019-08-08 06:58

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.

查看更多
登录 后发表回答