@@ -2622,8 +2622,6 @@ another build. The trigger will be executed in the context of the
26222622downstream build, as if it had been inserted immediately after the
26232623` FROM ` instruction in the downstream Dockerfile.
26242624
2625- Any build instruction can be registered as a trigger.
2626-
26272625This is useful if you are building an image which will be used as a base
26282626to build other images, for example an application build environment or a
26292627daemon which may be customized with user-specific configuration.
@@ -2666,11 +2664,26 @@ ONBUILD ADD . /app/src
26662664ONBUILD RUN /usr/local/bin/python-build --dir /app/src
26672665```
26682666
2667+ ### Copy or mount from stage, image, or context
2668+
2669+ As of Dockerfile syntax 1.11, you can use ` ONBUILD ` with instructions that copy
2670+ or mount files from other stages, images, or build contexts. For example:
2671+
2672+ ``` dockerfile
2673+ # syntax=docker/dockerfile:1.11
2674+ FROM alpine AS baseimage
2675+ ONBUILD COPY --from=build /usr/bin/app /app
2676+ ONBUILD RUN --mount=from=config,target=/opt/appconfig ...
2677+ ```
2678+
2679+ If the source of ` from ` is a build stage, the stage must be defined in the
2680+ Dockerfile where ` ONBUILD ` gets triggered. If it's a named context, that
2681+ context must be passed to the downstream build.
2682+
26692683### ONBUILD limitations
26702684
26712685- Chaining ` ONBUILD ` instructions using ` ONBUILD ONBUILD ` isn't allowed.
26722686- The ` ONBUILD ` instruction may not trigger ` FROM ` or ` MAINTAINER ` instructions.
2673- - ` ONBUILD COPY --from ` is [ not supported] ( https://github.com/moby/buildkit/issues/816 ) .
26742687
26752688## STOPSIGNAL
26762689
0 commit comments