mirror of https://github.com/docker/docs.git
Call out FROM can take a previous stage (#9566)
The included example could be improved with a more concrete use case, but illustrates the capability as is.
This commit is contained in:
parent
06c7f18df8
commit
eeea0d586a
|
|
@ -181,3 +181,19 @@ if necessary and copies the artifact from there. The syntax is:
|
|||
COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
|
||||
```
|
||||
|
||||
## Use a previous stage as a new stage
|
||||
|
||||
You can pick up where a previous stage left off by referring to it when using the `FROM` directive. For example:
|
||||
|
||||
```Dockerfile
|
||||
FROM alpine:latest as builder
|
||||
RUN apk --no-cache add build-base
|
||||
|
||||
FROM builder as build1
|
||||
COPY source1.cpp source.cpp
|
||||
RUN g++ -o /binary source.cpp
|
||||
|
||||
FROM builder as build2
|
||||
COPY source2.cpp source.cpp
|
||||
RUN g++ -o /binary source.cpp
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in New Issue