Skip to content
masterclass Buddy

Docker · Directive

ONBUILD

ONBUILD saves a Dockerfile instruction for a later build. When another Dockerfile uses the image with FROM, Docker runs the saved instruction in that child build.

Last updated

Syntax

ONBUILD <INSTRUCTION>

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • FROM
  • ADD
  • COPY
  • RUN
  • Dockerfile syntax
  • multi-stage builds

Source: Dockerfile reference. Checked 2026-11-03.