Docker cache from command for new pulled images doesnt work

  caching, docker, docker-build, docker-image, dockerfile

I understand that Docker –cache-from command will restore cache from pulled images when building a different one. Am I wrong? Whenever I create a new image, delete it and its dangling cache, pull it and build it again, it will not use the newly downloaded image as cache. Below are the commands for my use case.

docker build --target base -t image:base .
docker push image:base
docker image rm image:base
docker builder prune
docker pull image:base
docker build --target base --cache-from image:base -t image:base .

If I don’t prune the cache, it will use it regardless of the –cache-from command being present or not. Therefore, how am I supposed to use –cache-from, and is there any possibility of restoring cache from pulled images without using docker load (because it takes a while)?

Source: Docker Questions

LEAVE A COMMENT