ONBUILD

The Dockerfile instruction that stores another instruction as a trigger to run later, when a different build names this image in its FROM line.

In more detail

The trigger does nothing in the build that declares it; it is saved in the image metadata and shown by docker image inspect under OnBuild. When a child Dockerfile starts FROM that image, the triggers run right after the child's FROM, using the child's build context. Triggers are not inherited by grandchild images, and because they hide steps from whoever reads the child Dockerfile, most teams use them sparingly.

Example

ONBUILD COPY app.py /app/

Related terms

Taught in

References

Certification courses