Home > other >  How to start docker build at a certain stage in a multi-stage build?
How to start docker build at a certain stage in a multi-stage build?

Time:10-23

Our application take a very long time to compile. Any change to the Dockerfile triggers a full-recomplile (which takes a very long time) The Dockerfile is a muli-stage build. I'm trying to work on the second stage. Is there any way to tell docker build to begin at the second stage?

FROM debian:latest AS builder

# 10-20 mins worth of stuff here

FROM alpine:latest AS runner
WORKDIR /

COPY --from=builder /work/myapp.zip .
RUN unzip myapp.zip -d /myapp

# and more stuff that I'm working on here

Is there some way to do docker build --begin-with runner?

CodePudding user response:

Docker build run from the last changed stage..

See here might help you rebuild docker image from specific step

CodePudding user response:

Actually the Docker build cache should handle such situations automatically. However this implementation has it's limits. It may not give you exactly what you want, but may be close.

Check out https://www.baeldung.com/linux/docker-build-cache

  • Related