From dacaa583fba562fd071cf200088df3a5384680c2 Mon Sep 17 00:00:00 2001 From: Marcus Cobden Date: Tue, 4 Nov 2014 10:02:24 +0000 Subject: [PATCH] Walk file tree in order for deterministic builds Python's `os.walk` does not order the lists of files and directories it returns, so in order to produce a consistent build context tarfile, they should be ordered. --- docker/utils/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 0853ac41..7cd3b1a4 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -72,7 +72,8 @@ def tar(path, exclude=None): fnames = [name for name in filenames if not fnmatch_any(os.path.join(relpath, name), exclude)] - for name in fnames: + dirnames.sort() + for name in sorted(fnames): arcname = os.path.join(relpath, name) t.add(os.path.join(path, arcname), arcname=arcname) for name in dirnames: