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
This commit is contained in:
Mohammed Naser 2022-03-30 00:20:36 -04:00
parent 081352b299
commit 8190671962
2 changed files with 7 additions and 4 deletions

View File

@ -73,10 +73,6 @@
- name: Create a manifest with multi architecture images - 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 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) - name: Wipe all images from the local cache (tagged in DockerHub)
command: docker rmi docker.io/library/alpine@{{ item.value }} command: docker rmi docker.io/library/alpine@{{ item.value }}

View File

@ -72,6 +72,13 @@ class Authorization(cherrypy.Tool):
return store[user] == password return store[user] == password
def unauthorized(self, scope): 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'] = ( cherrypy.response.headers['www-authenticate'] = (
'Bearer realm="%s/auth/token",scope="%s"' % ( 'Bearer realm="%s/auth/token",scope="%s"' % (
self.public_url, scope) self.public_url, scope)