Merge pull request #50415 from thaJeztah/push_no_empty_body_step1

client: always send (empty) body on push
This commit is contained in:
Sebastiaan van Stijn
2025-07-16 19:45:17 +02:00
committed by GitHub

View File

@@ -72,5 +72,15 @@ func (cli *Client) tryImagePush(ctx context.Context, imageID string, query url.V
hdr.Set(registry.AuthHeader, registryAuth)
}
}
return cli.post(ctx, "/images/"+imageID+"/push", query, nil, hdr)
// Always send a body (which may be an empty JSON document ("{}")) to prevent
// EOF errors on older daemons which had faulty fallback code for handling
// authentication in the body when no auth-header was set, resulting in;
//
// Error response from daemon: bad parameters and missing X-Registry-Auth: invalid X-Registry-Auth header: EOF
//
// We use [http.NoBody], which gets marshaled to an empty JSON document.
//
// see: https://github.com/moby/moby/commit/ea29dffaa541289591aa44fa85d2a596ce860e16
return cli.post(ctx, "/images/"+imageID+"/push", query, http.NoBody, hdr)
}