docker-py
docker-py copied to clipboard
Reset uid and gid to 0 when creating the context tar file.
When the user provides a directory as context docker-py tars it and sends it to the docker engine. However, in contrast to docker-cli, docker-py does not reset the uid and gid of the files in the tar archive to 0. This leads to docker build cache misses when the ownership of files in the context changes. This PR adds this to docker-py such that a change of the file ownership does not invalidate build caches. docker-cli already does so. Hence docker-py is aliged with docker-cli with this PR.
The attached zip file creates two images (by running build.py) with exaclty the same context directory except a different group for one file in the context being COPY'ed in the Dockerfile. At the end the ID of the two images are printed. Without this patch the IDs are different, with this patch the IDs are the same. To run build.py from the zip file you need to adapt the group names in build.py, see the comment in the file.