Is there a way to tag a previous layer in a docker image or revert a commit?

前端 未结 1 967
忘了有多久
忘了有多久 2021-01-13 05:36

Let\'s say there is a docker image, someone makes changes to it and then pushes it up to a docker repository. I then pull down the image. Is there a way to then take that im

相关标签:
1条回答
  • 2021-01-13 06:36

    You can, by tagging build layers of the image if you have access to them. As described here.

    In your case what could be happening is that from version v1.10.0 forward they've changed the way that the docker engine handles content addressability. This is being heavily discussed here.

    What it means is that you won't have access to the build layers unless you built this image in the current machine or exported and loaded by combining:

    docker save imagename build-layer1 build-layer2 build-layer3 > image-caching.tar
    docker load -i image-caching.tar
    

    A user has posted a handy way to save that cache in the discussion I've mentioned previously:

    docker save imagename $(sudo docker history -q imagename | tail -n +2 | grep -v \<missing\> | tr '\n' ' ') > image-caching.tar
    

    This should collect all the build layers of the given image and save them to a cache tar file.

    0 讨论(0)
提交回复
热议问题