Zum Inhalt springen

Interact with the Container Registry: Docker, Crane and API

Zuletzt aktualisiert am

STACKIT Container Registry is built upon the official, OCI-compliant distribution image maintained by the Docker team. Because it strictly follows Open Container Initiative (OCI) specifications, you can interact with your STACKIT registry using standard Docker commands, CI/CD integrations, API calls, or any other OCI-compatible client tooling.

Below are examples of how to interact with your registry using some of the most common methods.

The standard Docker CLI is the most common way to authenticate, push, and pull images.

Before interacting with your registry, you must authenticate. You can use your STACKIT user credentials or a project-specific Robot Account.

Terminal window
docker login <registry-domain>

(You will be prompted to enter your username and password/token).

To push a local image to your Container Registry, you first need to tag it with your registry domain and project name.

Terminal window
# 1. Tag the local image
docker tag my-local-image:latest <registry-domain>/<project-name>/my-local-image:v1.0.0
# 2. Push the image to STACKIT
docker push <registry-domain>/<project-name>/my-local-image:v1.0.0

To pull an image from your registry to your local machine or server:

Terminal window
docker pull <registry-domain>/<project-name>/my-local-image:v1.0.0

How-to use Crane (and robot account constraints)

Section titled “How-to use Crane (and robot account constraints)”

Crane is a powerful tool by Google designed specifically for interacting with remote images and registries without needing the Docker daemon.

You can use crane to easily tag or copy images entirely server-side:

Terminal window
# Authenticate
crane auth login <registry-domain> -u <username> -p <password-or-token>
# Tag an existing image in the registry
crane tag <registry-domain>/<project-name>/my-app:v1.0.0 v1.0.1
# Inspect an image manifest
crane manifest <registry-domain>/<project-name>/my-app:v1.0.0

Important Constraint: Crane and robot accounts

Section titled “Important Constraint: Crane and robot accounts”

Tools like crane are frequently used in automation pipelines to manage images across multiple projects or registries simultaneously (for example, copying an image from a staging project to a production project).

Please be aware of the following limitation: Currently, STACKIT Container Registry Robot Accounts are strictly limited to a “one project scope.”

If you attempt to use a single Robot Account with crane (or any other tool) to operate across more than one Harbor project at the same time, the operation will fail with an authorization error. For cross-project automation, you must either use STACKIT user credentials or handle the cross-project movement in distinct steps using separate Robot Accounts for each project.

Because STACKIT Container Registry utilizes Harbor, you can directly interact with the Harbor REST API to fetch metadata, manage repositories, or integrate with custom dashboards.

Example: Fetching repositories in a project

Section titled “Example: Fetching repositories in a project”

You can use curl to query the API. To list the repositories within a specific project, use the following command (replace the placeholders with your actual data):

Terminal window
curl -u '<username>':'<password-or-token>' \
-X GET \
-H "Accept: application/json" \
"https://<registry-domain>/api/v2.0/projects/<project-name>/repositories"

For complete API endpoints and capabilities, please refer to the official Harbor API documentation.