docker: extracting a layer from a image

前端 未结 5 1484
既然无缘
既然无缘 2020-12-28 20:11

Let\'s take the whalesay images as an example. docker history shows the following:

IMAGE               CREATED             CREATED BY                    


        
5条回答
  •  旧巷少年郎
    2020-12-28 20:53

    While not capable of extracting a specific layer, the docker-save-last-layer command line utility is made to extract the last layer only. Combined with docker build --squash you can avoid exporting the base layers. This may help to accomplish your goals.

    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. This makes it 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
    

提交回复
热议问题