On CI the dockerfiles directories have example script that clone repo, use cache and logs. Some of the files end up owned by nobody on the host machine and can not be deleted. That causes docker-pkg to fail when creating the build environment despite a .dockerignore file.
def _create_build_environment(self): if self.build_path is not None: # Build path already created, assume it's all good return base = tempfile.mkdtemp(prefix='docker-pkg-{name}'.format(name=self.safe_name)) build_path = os.path.join(base, 'context') shutil.copytree(self.path, build_path) self.build_path = build_path
It copies the whole tree (shutil.copytree).
The python docker module might have an helper to build the context and honor .dockerignore.