Docker Community Forums

Share and learn in the Docker community.

Create several images from single Dockerfile

docker

(Daoudatraore) #1

Hey guys,

Can i create several image from one Dockerfile using multi-stage build, then reference those images in a docker-compose.yml file to manage them?

FROM java8 as builder
WORKDIR
COPY
mvn clean package

FROM java8 as app1
COPY --from=builder ./target/app.jar .
CMD java -jar app.jar

FROM java8 as app2
COPY --from=builder ./target/app.jar .
CMD java -jar app.jar

FROM java8 as app3
COPY --from=builder ./target/app.jar .
CMD java -jar app.jar