From upstream: https://github.com/docker/distribution/commit/8b706168467e9352e0c567633c3c264a340de79d