I have got my docker image called
during build I am not specifying
Is it possible to know which image is used during build as cache?
DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. It only takes a minute to sign up.Sign up to join this community
The default location of the image cache is under
The "cache" features in docker are more like a communication vehicle for the documentation, than a proper, separate data structure. There is no special storage which makes up this cache.
For every filesystem-modifying line (RUN/ADD/...) in your Dockerfile,
docker run creates a new image, with the image of the previous line (or the FROM line at the beginning) as the base. Docker uses the hashes of the previous image together with the hash of the RUN line to calculate the hash of the new image. If that new hash already exists, then it is reused.
Those intermediate images are exactly the same kind of object in storage as your final image (i.e., a subdirectory of
/var/lib/docker, by default), they just don't have a tag pointing to them, so they can be cleaned away somewhat more aggressively by
docker image prune -a, for example. But technically they are just the same as tagged images.
All options which talk about caches in the docker documentation (i.e.,
build --squashetc.) just modify the behaviour so that said image handling a bit different, but under the hood there's just images, nothing special related to caching.