@@ -2622,8 +2622,6 @@ another build. The trigger will be executed in the context of the
2622
2622
downstream build, as if it had been inserted immediately after the
2623
2623
` FROM ` instruction in the downstream Dockerfile.
2624
2624
2625
- Any build instruction can be registered as a trigger.
2626
-
2627
2625
This is useful if you are building an image which will be used as a base
2628
2626
to build other images, for example an application build environment or a
2629
2627
daemon which may be customized with user-specific configuration.
@@ -2666,11 +2664,26 @@ ONBUILD ADD . /app/src
2666
2664
ONBUILD RUN /usr/local/bin/python-build --dir /app/src
2667
2665
```
2668
2666
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
+
2669
2683
### ONBUILD limitations
2670
2684
2671
2685
- Chaining ` ONBUILD ` instructions using ` ONBUILD ONBUILD ` isn't allowed.
2672
2686
- The ` ONBUILD ` instruction may not trigger ` FROM ` or ` MAINTAINER ` instructions.
2673
- - ` ONBUILD COPY --from ` is [ not supported] ( https://github.com/moby/buildkit/issues/816 ) .
2674
2687
2675
2688
## STOPSIGNAL
2676
2689
0 commit comments