From upstream: https://github.com/docker/distribution/commit/74f429a5ad400894cd0a9cf96a6204696887b37a