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
- FROM — The Dockerfile instruction that picks the base image a build starts from.
- base image — The image a Dockerfile starts from with FROM, which supplies the operating system files and often a language runtime.
- Dockerfile — A text file of instructions, such as FROM, COPY and RUN, that tells Docker how to build an image.
Taught in
- FROM, WORKDIR, COPY And ADD — Docker Architecture & Production Containers
- Twelve Lines, Ten Warnings: Dockerfile Instructions And hadolint — Docker Certified Associate (DCA) Exam Prep