Reputation: 14408
I am trying to use Docker Http V2 API to push an image following this link; https://docs.docker.com/registry/spec/api/#pushing-an-image; I could get the "Location" header value after POSTing to the /blob/uploads but the chunk/monolithic upload is not working - getting 404 not found - even though I am setting the required headers.
String url = String.format("https://%s/v2/%s/blobs/uploads/", dockerRegistry, repository);
Mono<ClientResponse> clientResponse = WebClient.create(url).post().header("Connection", "close").exchange();
ClientResponse clientResponse2 = clientResponse.block();
HttpHeaders asHttpHeaders = clientResponse2.headers().asHttpHeaders();
String location = asHttpHeaders.get("Location").get(0);
String uploadUrl = ("https://" + dockerRegistry + location);
Mono<ClientResponse> clientResponse3 =
WebClient.create(uploadUrl).patch().contentLength(bytes.length)
.header("Content-Range", "0-" + Integer.toString(bytes.length - 1))
.contentType(MediaType.APPLICATION_OCTET_STREAM).header("Connection", "close")
.bodyValue(bytes).exchange()
.timeout(Duration.ofHours(1));
ClientResponse clientResponse4 = clientResponse3.block(); // 404 NOT FOUND
HttpHeaders asHttpHeaders = clientResponse4.headers().asHttpHeaders();
return asHttpHeaders.get("Location").get(0);
I see no much room to fail here but I am still getting the error. Can someone help me here? Bw, I am trying to connect to Azure Container Registry here.
Upvotes: 1
Views: 564