How does Docker handle file system layers and image caching?
Docker’s use of file system layers and image caching is fundamental to its efficiency, allowing it to speed up builds and reduce storage needs. How do these layered file systems work, and what strategies does Docker use to cache images during builds? Specifically, how do changes in Dockerfile instructions impact caching, and how can developers optimize their Dockerfiles to take full advantage of the cache while minimizing rebuild times?