I need to run docker in a server without network. So I need to use docker save to save the whole image to a tar file and copy it to the server. That’s fine.
But Every time I add new tools to my image, I have to use docker save the very large tar file and copy it. It’s very time consuming to save and copy.
Then I find there is a cherry pick version in the document(docker save | Docker Documentation). But it seems the diff version is very large. Here are my steps:
- docker run -it lili/transformers:v3 bash
- install some tools by apt install
- docker commit this container as lili/transformers:v4
- docker save -o diff.tar lili/transformers:v3 lili/transformers:v4
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
lili/transformers v4 98f22a3d0d02 32 minutes ago 12.8GB
lili/transformers v3 659eb3fa2163 26 hours ago 12.8GB
$ docker history lili/transformers:v4
IMAGE CREATED CREATED BY SIZE COMMENT
98f22a3d0d02 54 minutes ago bash 1.53MB
659eb3fa2163 27 hours ago bash 37.2MB
64acb2d9c6e3 27 hours ago bash 202MB
5221c70a1353 7 days ago bash 5.59GB
fa7573004516 2 months ago RUN |1 TARGETARCH=amd64 /bin/sh -c apt-get u… 2.82GB buildkit.dockerfile.v0
2 months ago LABEL com.nvidia.cudnn.version=8.1.1.33 0B buildkit.dockerfile.v0
du -sh diff.tar
12G diff.tar
It seems the cherry pick version’s size is not smaller as I expected.