Docker Registry

Run implementa el subconjunto Docker Registry v2 orientado a push necesario para subir blobs y manifiestos. No es una API registry completa para pull.

Autenticación

1docker login run.hola.cloud

Endpoints soportados

  • GET /v2/
  • HEAD /v2/*
  • POST /v2/:repository/blobs/uploads/
  • PATCH /v2/:repository/blobs/uploads/:uuid
  • PUT /v2/:repository/blobs/uploads/:uuid
  • PUT /v2/:repository/manifests/:reference

Ejemplo de manifiesto:

curl -X PUT "https://api.hola.cloud/v2/my-project/my-app/manifests/latest" \
  -H "Authorization: Basic <base64-credentials>" \
  -H "Content-Type: application/vnd.docker.distribution.manifest.v2+json" \
  --data-binary @manifest.json
PUT /v2/my-project/my-app/manifests/latest HTTP/1.1
Host: api.hola.cloud
Authorization: Basic <base64-credentials>
Content-Type: application/vnd.docker.distribution.manifest.v2+json

@manifest.json
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	body := "@manifest.json"

	req, err := http.NewRequest("PUT", "https://api.hola.cloud/v2/my-project/my-app/manifests/latest", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Basic <base64-credentials>")
	req.Header.Set("Content-Type", "application/vnd.docker.distribution.manifest.v2+json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$body = '@manifest.json';

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v2/my-project/my-app/manifests/latest',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Authorization: Basic <base64-credentials>',
        'Content-Type: application/vnd.docker.distribution.manifest.v2+json',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "Authorization": "Basic <base64-credentials>",
    "Content-Type": "application/vnd.docker.distribution.manifest.v2+json",
}

body = "@manifest.json"

response = requests.request(
    "PUT",
    "https://api.hola.cloud/v2/my-project/my-app/manifests/latest",
    headers=headers,
    data=body
)

print(response.text)
const body = "@manifest.json";

const response = await fetch("https://api.hola.cloud/v2/my-project/my-app/manifests/latest", {
  method: "PUT",
  headers: {
    "Authorization": "Basic <base64-credentials>",
    "Content-Type": "application/vnd.docker.distribution.manifest.v2+json"
  },
  body
});

console.log(await response.text());
const body = "@manifest.json";

const response = await fetch("https://api.hola.cloud/v2/my-project/my-app/manifests/latest", {
  method: "PUT",
  headers: {
    "Authorization": "Basic <base64-credentials>",
    "Content-Type": "application/vnd.docker.distribution.manifest.v2+json"
  },
  body
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var body = """
@manifest.json
""";

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v2/my-project/my-app/manifests/latest"))
            .method("PUT", HttpRequest.BodyPublishers.ofString(body))
            .header("Authorization", "Basic <base64-credentials>")
            .header("Content-Type", "application/vnd.docker.distribution.manifest.v2+json")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Comentarios

Deja un comentario