The ONBUILD instruction

The ONBUILD instruction registers a build instruction to an image and this gets triggered when another image is built using this image as its base image. Any build instruction can be registered as a trigger and those instructions will be triggered immediately after the FROM instruction in the downstream Dockerfile. Thus, the ONBUILD instruction can be used for deferring the execution of the build instruction from the base image to the target image.

The syntax of the ONBUILD instruction is as follows:

ONBUILD <INSTRUCTION> 

Here, <INSTRUCTION> is another Dockerfile build instruction, which will be triggered later. The ONBUILD instruction does not allow the chaining of another ONBUILD instruction. In addition, it does not allow the FROM and MAINTAINER instruction as an ONBUILD trigger.

Here is an example of the ONBUILD instruction:

ONBUILD ADD config /etc/appconfig 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset