We are attempting to establish a cache for the docker run
command to avoid the repetitive downloading of images each time our pipeline is executed. This effort is primarily to instantiate a database instance for use in integration tests by our service.
From my understanding, Docker on Linux stores the image cache within the /var/lib/docker
directory. Our initial approach involved preserving the contents of the /var/lib/docker
folder across multiple executions. However, this method resulted in the first execution successfully downloading and using the image, whereas subsequent attempts led to a failure, accompanied by an error message stating “layer does not exist”.
This suggests that the folder’s contents may not be consistently valid across different containers. Could you provide insights into why this issue occurs and recommend strategies to effectively cache images and layers for successive pipeline runs?
Thanks