Browse code

Updated the explanation of ONBUILD in best-practices doc

Signed-off-by: Tonny Xu <tonny.xu@gmail.com>

Tonny Xu authored on 2015/03/31 11:44:58
Showing 1 changed files
... ...
@@ -398,7 +398,15 @@ troubleshoot, and maintain.
398 398
 
399 399
 ### [`ONBUILD`](https://docs.docker.com/reference/builder/#onbuild)
400 400
 
401
-`ONBUILD` is only useful for images that are going to be built `FROM` a given
401
+An `ONBUILD` command executes after the current `Dockerfile` build completes.
402
+`ONBUILD` executes in any child image derived `FROM` the current image.  Think
403
+of the `ONBUILD` command as an instruction the parent `Dockerfile` gives
404
+to the child `Dockerfile`.
405
+
406
+A Docker build executes `ONBUILD` commands before any command in a child
407
+`Dockerfile`.
408
+
409
+`ONBUILD` is useful for images that are going to be built `FROM` a given
402 410
 image. For example, you would use `ONBUILD` for a language stack image that
403 411
 builds arbitrary user software written in that language within the
404 412
 `Dockerfile`, as you can see in [Ruby’s `ONBUILD` variants](https://github.com/docker-library/ruby/blob/master/2.1/onbuild/Dockerfile).