Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to search the registry from the command line #3632

Closed
DavidRodHub opened this issue Nov 17, 2017 · 7 comments
Closed

How to search the registry from the command line #3632

DavidRodHub opened this issue Nov 17, 2017 · 7 comments

Comments

@DavidRodHub
Copy link

Installed harbor version 1.2

How to search docker-registry from the command line. The docker search command returns "Unexpected status code 404"

docker search docker-registy-host.com/project/imageXXX
Error response from daemon: Unexpected status code 404

@yixingjia
Copy link
Contributor

By default search use v1 api, Harbor disable the V1 api by default.

@reasonerjt
Copy link
Contributor

There's no search API in registry V2.

@DavidRodHub
Copy link
Author

I found that I can search the harbor registry from the command line using a tool called "docker-ls" [https://github.com/mayflower/docker-ls ], but found that harbor doesn't allow you to search using docker-ls unless your an admin on Harbor. Is that correct? If a user can log-on to Harbor, why aren't they not allowed to search the registry from the command line if they can search the registry using the harbor GUI?

@DavidRodHub
Copy link
Author

As the admin user, tried listing the harbor docker registry using CLI command curl.
curl -v -u admin:harbor1234 https://docker-reg.company.com/v2/_catalog

Get HTTP/1.1 401 Unauthorized

Would like to be able to list the repositories from the command line using curl if possible or any other method. Not sure what I'm doing wrong. Note that from the command line I can run "docker login https://docker-reg.company.com" successfully from the command line.

Here's the full output of the curl command

  • Trying 10.20.1.201...
  • Connected to docker-reg.company.com (10.20.1.201) port 443 (#0)
  • found 148 certificates in /etc/ssl/certs/ca-certificates.crt
  • found 592 certificates in /etc/ssl/certs
  • ALPN, offering http/1.1
  • SSL connection using TLS1.2 / ECDHE_RSA_AES_256_GCM_SHA384
  •    server certificate verification OK
    
  •    server certificate status verification SKIPPED
    
  •    common name: *.company.com (matched)
    
  •    server certificate expiration date OK
    
  •    server certificate activation date OK
    
  •    certificate public key: RSA
    
  •    certificate version: #3
    
  •    subject: CN=*.company.com
    
  •    start date: Thu, 03 Dec 2015 16:39:42 GMT
    
  •    expire date: Tue, 05 Dec 2017 10:01:49 GMT
    
  •    issuer: C=US,O=GeoTrust Inc.,CN=RapidSSL SHA256 CA - G3
    
  •    compression: NULL
    
  • ALPN, server accepted to use http/1.1
  • Server auth using Basic with user 'admin'

GET /v2/_catalog HTTP/1.1
Host: docker-reg.company.com
Authorization: Basic YWRtaW46TXljb21vc2ktYXJjaGkyMDE1
User-Agent: curl/7.47.0
Accept: /

< HTTP/1.1 401 Unauthorized
< Server: nginx/1.11.13
< Date: Mon, 04 Dec 2017 23:18:51 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 145
< Connection: keep-alive
< Docker-Distribution-Api-Version: registry/2.0
< Set-Cookie: beegosessionID=c180689fb764586e5b21a6eb44db0231; Path=/; HttpOnly
< Www-Authenticate: Bearer realm="https://docker-reg.company.com/service/token",service="harbor-registry",scope="registry:catalog:"
<
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"registry","Class":"","Name":"catalog","Action":"
"}]}]}

  • Connection #0 to host docker-reg.company.com left intact

@gcstang
Copy link

gcstang commented Dec 22, 2017

Install Swagger and there are many Rest API's you can call including search via curl.

curl -X GET --header 'Accept: application/json' 'https://<youhostname>/api/search?q=registry'

@DavidRodHub
Copy link
Author

OK, thanks for you support

@shibd
Copy link

shibd commented Nov 12, 2018

所以这个问题的解决方案是?harbor有计划支持V1版本的API吗,https://github.com/docker/distribution/issues/206,docker distribution那边貌似还没支持V2版本。针对docker search host:port/image 大家是怎么做的呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants