Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker save only non public layers

Tags:

docker

I can export images with

docker save -o <save image to path> <image name>

but this will pack all layers, and the file is big

is there a possibility to pack only layers which are not public available, so only the difference to the last public layer is exported?

like image 535
wutzebaer Avatar asked Aug 25 '16 10:08

wutzebaer


1 Answers

The docker-save-last-layer command line utility combined with docker build --squash is made to accomplish exactly this.

It exports only the last layer of the specified docker image.

It works by using a patched version of the docker daemon inside a docker image that can access the images on your host machine. So it doesn't require doing a full docker save before using it like the undocker answer. This makes it much more performant for large base images.

Typical usage is simple and looks like:

pip install d-save-last

docker build --t myimage --squash .
d-save-last myimage -o ./myimage.tar
like image 59
brthornbury Avatar answered Nov 16 '22 02:11

brthornbury