Docker Community Forums

Share and learn in the Docker community.

Help with understanding docker save/load for images please

docker

(Cfoutsz6501) #1

I hope this is a problem with my process, since I’m relatively new to docker.

I’m trying save a cached image and re-use it so my future docker image builds go faster. I do the following

$ cd to /path/with_dockerfile
# Build the image, produces imaged with Id 8a91e7fe5373
$ docker build .
# Do a second docker build, just to prove caching; this one indeed uses the cache
$ docker build .
# Save the image to a tarball
$ docker save -o /tmp/image.tar 8a91e7fe5373
# Delete the cached image, NOT the tarball
$ docker image rm 8a91e7fe5373 --force
# Load the tarball image
$ docker load -i /tmp/image.tar
# Rerun docker build
$ docker build .

In the last step, I expect the build to be using the cache, it it doesn’t! docker build sooks just like the first docker build. I also of course do NOT see the image when I do a “docker images.” What am I missing?