Docker - which cache is used to build image
Answer

The default location of the image cache is under /var/lib/docker.

More answer

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 --rm=false, 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.