Is there a way to mark the previous layer in the docker image or return a commit?

Say there is an image of a docker, someone makes changes to it, and then pushes it into the docker repository. Then I take an image. Is there any way to then take this image and start the container from the previous layer? Run the version before making any changes.

If I run docker history, it will look something like this:

docker history imagename:tag IMAGE CREATED CREATED BY SIZE COMMENT 3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B <missing> 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB <missing> 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB <missing> 6 weeks ago /bin/sh -c #(nop) ADD jessie.tar.xz in / 121 MB <missing> 6 weeks ago /bin/sh -c #(nop) MAINTAINER ssss <ad 0 B <missing> 9 months ago 0 B 

It seems that I can run an earlier version if I figure out a way to somehow mark or identify previous layers of the image.

+2
source share
1 answer

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

In your case, what could happen is that from v1.10.0 onward they have changed the way the docker engine handles content addressing , discussed here .

What does this mean that you will not have access to the assembly layers if you did not build this image on the current computer or exported or downloaded by combining:

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

The user posted a convenient way to save this cache in the discussion that I talked about earlier:

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

This should collect all the assembly layers of the given image and save them in the tar file of the cache file.

+3
source

Source: https://habr.com/ru/post/1275936/


All Articles