thomas-bc
thomas-bc

Reputation: 79

Retrieve file that was deleted during the image build

I have a docker image. When I use the docker history command on the image, I can see

85d9bf810d44        9 days ago          /bin/sh -c apk add vim                          26.9MB
<missing>           9 days ago          /bin/sh -c apk update                           1.78MB
<missing>           9 days ago          /bin/sh -c rm -f file.txt                           0B
<missing>           9 days ago          /bin/sh -c a=$(base64 -d < file.txt) && echo $a …   49B
<missing>           9 days ago          /bin/sh -c #(nop) COPY file:98f5646751cb4985…   68B
<missing>           6 weeks ago         /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B
<missing>           6 weeks ago         /bin/sh -c #(nop) ADD file:f17f65714f703db90…   5.57MB

So there was a file.txt at some point in the image, but it was later removed. I would like to know if there is a way to retrieve the content of that file from the image layers.
I have looked into Dive and all sorts of stuff. Also navigating through Docker's overlay files (as indicated here) seemed promising, but I am using macOS and I couldn't find the corresponding directories...

Upvotes: 1

Views: 554

Answers (1)

Itamar Turner-Trauring
Itamar Turner-Trauring

Reputation: 3900

docker image save will export a tarball that contains a tarball per layer.

https://docs.docker.com/engine/reference/commandline/image_save/

Upvotes: 1

Related Questions