How to save transfer cache to a different host from a docker

When I do a "docker-compose build" it takes like 30m to complete. When I re-run "docker-compose build" everything is cached and it takes like 1m to complete.

I want to transfer this cache to another machine. I thought I could iterate over all images in "docker images" and "docker save" them, and then simply copy the tar files over and "docker load" them.

No love. It seems to get a large portion of the cache, but "docker-compose build" is STILL running steps in the Dockerfile.

I can reproduce this locally. For instance:

# Do a docker-compose build (takes 30m):
docker-compose build
# Verify that a docker-compose build uses cache (takes 1m):
docker-compose build
# Save all images to /tmp/[IMAGE.TAG].tar:
docker images | grep -v REPOSITORY | grep -v '<none>' | awk '{print "docker save "$1" > /tmp/"$1"."$2".tar"}' > ./run-this.sh

# Now delete all cache:
docker rmi $(docker images -q)
docker rm $(docker ps -a -q)

# Load in all tar files:
for f in /tmp/*.tar; do docker load < $f ; done

# Verify docker-compose takes 1m:
docker-compose build

# Dang. It takes ~15m. It should have taken 1m.
# I must not be saving some images!

How do I programmatically save ALL cache from a docker-compose build?

This is very similar to this: How to copy docker images from one host to another without via repository?

链接地址: http://www.djcxy.com/p/18272.html

上一篇: 我可以自定义标题吗?

下一篇: 如何将传输缓存保存到泊坞窗的其他主机