From upstream: https://github.com/docker/distribution/commit/15b0204758876befc0664b64ccfb05f924627b2d