Is it possible to build a Dockerfile from a specific step

Hi !

I would like to know if it’s possible to build a dockerfile from a specific step ?

As an example :
I’ve got my dockerfile with this in :

RUN apt update \
&& apt update \
&& apt install vim \
&&  git
RUN git clone myproject \
git checkout dev_branch
RUN do some things

Is it possible to alway start from the step 2 (git step) to force the dockerfile to always do the git clone et git checkout ?
As something like
docker build mydockerfile --step:2 ?

Or should I always do :
docker build --no-cache -t user/image-name ?

You should check out your repository before you run docker build, probably even add the Dockerfile to the repository itself.

This avoids a number of practical problems: needing to avoid Docker’s build-cache mechanism as you say; needing to install git in the image when your application doesn’t use it; and not leaking secrets like your ssh private key to future users of the image.