Managing a Headless Harbor Registry via Curl API
When a Harbor registry is deployed on a cloud ECS without a public IP or GUI, you can still list projects, view repositories, retrieve image digests, and delete images entirely through RESTful API calls using curl, followed by a manual garbage‑collection step to reclaim disk space.
Scenario
A student set up a private Harbor registry on a cloud ECS instance running Linux. The installation was performed from an offline package, so no graphical web UI was available, and the server had no public IP, allowing only internal‑network access. While pushing images succeeded, the user could not view or delete images through a browser.
Problem Analysis
Harbor is fundamentally a RESTful service; even without the Web UI, all management functions can be performed via its API using standard curl commands.
Solution: Command‑Line Management
1. List All Projects
curl -u admin:Harbor12345 -X GET "https://192.168.40.62/api/v2.0/projects" -kThe command returns a JSON array of projects. Example output (truncated) is shown below:
2. List Repositories in a Project
Assuming the project name is alpine:
curl -u admin:Harbor12345 -X GET "https://192.168.40.62/api/v2.0/projects/alpine/repositories" -kThe response lists the repositories under that project:
3. Retrieve Image Digest (for Deletion)
curl -u admin:Harbor12345 -X GET "https://192.168.40.62/api/v2.0/projects/alpine/repositories/alpine/artifacts" -kThe JSON output contains a digest field for each artifact. Copy the desired digest value:
4. Delete the Specified Image
curl -u admin:Harbor12345 -X DELETE "https://192.168.40.62/api/v2.0/projects/alpine/repositories/alpine/artifacts/sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" -kVerify deletion:
curl -u admin:Harbor12345 -X GET "https://192.168.40.62/api/v2.0/projects/alpine/repositories/alpine/artifacts" -kThe command now returns an empty array [], confirming the image has been removed.
Additional Reminder
Harbor’s delete operation is logical only. To actually free disk space, trigger a garbage‑collection (GC) on the Harbor host after deletions.
Conclusion
Even without a graphical interface, Harbor can be fully managed through its RESTful API. Mastering these curl‑based commands is a valuable skill for DevOps engineers, especially in environments where the registry is isolated from the public network.
Full-Stack DevOps & Kubernetes
Focused on sharing DevOps, Kubernetes, Linux, Docker, Istio, microservices, Spring Cloud, Python, Go, databases, Nginx, Tomcat, cloud computing, and related technologies.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
