Work around bug in Docker 28.3.3 that prevents pushing to registry without authentication. (#1110)

This commit is contained in:
Felix Fontein
2025-08-03 15:19:16 +02:00
committed by GitHub
parent cfd59ac9e5
commit e1920d1cc7
3 changed files with 15 additions and 4 deletions
+6 -2
View File
@@ -72,6 +72,7 @@ image:
sample: {}
"""
import base64
import traceback
from ansible.module_utils.common.text.converters import to_native
@@ -142,8 +143,11 @@ class ImagePusher(DockerBaseClass):
headers = {}
header = get_config_header(self.client, push_registry)
if header:
headers['X-Registry-Auth'] = header
if not header:
# For some reason, from Docker 28.3.3 on not specifying X-Registry-Auth seems to be invalid.
# See https://github.com/moby/moby/issues/50614.
header = base64.urlsafe_b64encode(b"{}")
headers['X-Registry-Auth'] = header
response = self.client._post_json(
self.client._url("/images/{0}/push", self.name),
data=None,