I have a long-running docker build process, so I would prefer not to disable caching for the entire build (with --no-cache). However, I would like to invalidate caching for a particular step.
I had a bright idea: remove the cached layer and rebuild so this has to rebuild.
I used:
docker build --progress=plain
to get hold of the sha of the cached layer:
#16 [stage-9 3/15] RUN pip install -r /tmp/requirements.lock
#16 sha256:e4ac79a1eac5702cd296ccf33a1cfa2e0c3890c77d42737dc62a3b26ac3e798e
#16 CACHED
But then I got this error
> docker rmi e4ac79a1eac5702cd296ccf33a1cfa2e0c3890c77d42737dc62a3b26ac3e798
Error: No such image: e4ac79a1eac5702cd296ccf33a1cfa2e0c3890c77d42737dc62a3b26ac3e798
Is there an (easy) way of deleting this layer?
Note: For most use cases (and maybe even this one) you might like to use the --no-cache option for docker build