Browse code

Follow #28926, fix docker save can't share layers in the tar archive.

After https://github.com/docker/docker/pull/28926, if saving multiple images
which have common layers at same time, the common layers can't share in the tar archive
because the hash ID changes because of the Create time. The Create time is used for
pre v1.9 which treat each layer as a image and make no sense for after v1.10.
To make the hash ID consistent and keep the image save from >1.10 working properly
on pre v1.9, using a constant Create time `time.Unix(0,0)`.

Signed-off-by: Lei Jitang <leijitang@huawei.com>

Lei Jitang authored on 2017/01/17 19:40:59
Showing 1 changed files
... ...
@@ -234,7 +234,9 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc
234 234
 	var foreignSrcs map[layer.DiffID]distribution.Descriptor
235 235
 	for i := range img.RootFS.DiffIDs {
236 236
 		v1Img := image.V1Image{
237
-			Created: img.Created,
237
+			// This is for backward compatibility used for
238
+			// pre v1.9 docker.
239
+			Created: time.Unix(0, 0),
238 240
 		}
239 241
 		if i == len(img.RootFS.DiffIDs)-1 {
240 242
 			v1Img = img.V1Image