I am fairly new to docker. I run docker build and at some point it fails (about 5 RUN statement). I found the issue and fixed in my docker file. Is there a way to restart build from where I left off or do I need to rerun full build?
If you re-run the same
docker build command, Docker will, at each step, see that it’s already done that step (and more specifically, previous layer ID + specific step => new layer ID) and skip over it. This is referred to as “layer caching”, and while it’s usually valuable, there is a
docker build --no-cache option to avoid it.
The corollary “gotcha” is that, if your Dockerfile contains a command like
git pull that doesn’t actually produce constant output, Docker will happily conclude that it’s already done that command and doesn’t need to repeat it. IMHO it’s better to run the
git pull outside the Dockerfile and pass the resulting contents as part of the build context, but I’ve also seen people who always use
--no-cache for this case.
That is excellent explanation.