From a6b9ca1c622a44d0e1124b9ea5ba70464e094d73 Mon Sep 17 00:00:00 2001 From: Markus Friedrich Date: Sat, 27 Jul 2019 09:47:34 +0200 Subject: [PATCH] Reset uid and gid to 0 when creating the context tar file. This is needed to avoid unexpected build cache invalidations due to changed ownership. docker-cli does it also this way. Signed-off-by: Markus Friedrich --- docker/utils/build.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/utils/build.py b/docker/utils/build.py index 4fa57518..8233436b 100644 --- a/docker/utils/build.py +++ b/docker/utils/build.py @@ -91,6 +91,11 @@ def create_archive(root, files=None, fileobj=None, gzip=False, # and directories executable by default. i.mode = i.mode & 0o755 | 0o111 + # reset uid and gid to 0 to avoid build cache invalidations due to + # changed ownership. (docker-cli does the same) + i.uid = 0 + i.gid = 0 + if i.isfile(): try: with open(full_path, 'rb') as f: