From b14161740bd87213cd81db0c803c46a69e2da97c Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Tue, 17 Jan 2017 05:40:59 -0500 Subject: [PATCH] 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 Upstream-commit: ee5228e799ab82e7f81a9673dec9228469c86dfd Component: engine --- components/engine/image/tarexport/save.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/engine/image/tarexport/save.go b/components/engine/image/tarexport/save.go index c85b1a2ba5..bab7a9611f 100644 --- a/components/engine/image/tarexport/save.go +++ b/components/engine/image/tarexport/save.go @@ -234,7 +234,9 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc var foreignSrcs map[layer.DiffID]distribution.Descriptor for i := range img.RootFS.DiffIDs { v1Img := image.V1Image{ - Created: img.Created, + // This is for backward compatibility used for + // pre v1.9 docker. + Created: time.Unix(0, 0), } if i == len(img.RootFS.DiffIDs)-1 { v1Img = img.V1Image