From 819067196252d22ff76537e20995f45cd60a42ff Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Wed, 30 Mar 2022 00:20:36 -0400 Subject: [PATCH] Fix "docker manifest create" issue This patch resolves the issue that causes Docker to fail when it runs the "docker manifest create" command since the registry does not mention that it supports the 2.0 API inside it's headers. Change-Id: I777bd4218c822fa665f0d29f573a6ae120194284 --- playbooks/functional-test/docker.yaml | 4 ---- zuul_registry/main.py | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/playbooks/functional-test/docker.yaml b/playbooks/functional-test/docker.yaml index 80436ca..0a80066 100644 --- a/playbooks/functional-test/docker.yaml +++ b/playbooks/functional-test/docker.yaml @@ -73,10 +73,6 @@ - name: Create a manifest with multi architecture images command: docker manifest create localhost:9000/alpine:3 localhost:9000/alpine:3-amd64 localhost:9000/alpine:3-arm64 - # NOTE(mnaser): This should fail because of the following bug: - # https://github.com/docker/cli/issues/3161 - register: result - failed_when: result.rc != 1 - name: Wipe all images from the local cache (tagged in DockerHub) command: docker rmi docker.io/library/alpine@{{ item.value }} diff --git a/zuul_registry/main.py b/zuul_registry/main.py index d88b8d4..03b3198 100644 --- a/zuul_registry/main.py +++ b/zuul_registry/main.py @@ -72,6 +72,13 @@ class Authorization(cherrypy.Tool): return store[user] == password def unauthorized(self, scope): + # NOTE(mnaser): This is to workaround the following Docker CLI bug and + # should be removed once it is fixed: + # + # https://github.com/docker/cli/issues/3161 + cherrypy.response.headers['Docker-Distribution-Api-Version'] = ( + 'registry/2.0' + ) cherrypy.response.headers['www-authenticate'] = ( 'Bearer realm="%s/auth/token",scope="%s"' % ( self.public_url, scope)