Harbor镜像仓库API操作及使用

小柒助手 Docker评论128.6K3字数 2085阅读6分57秒阅读模式

注:

Harbor镜像仓库地址:172.168.1.249
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

# 获取项目信息
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/projects/2"
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

# 获取所有项目信息
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/projects?"
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

# 搜索镜像
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/search?q=asset"
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

# 删除项目
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

curl -u "admin:Harbor12345" -X DELETE -H "Content-Type: application/json" "http://172.168.1.249/api/projects/3"
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

# 创建项目
文章源自小柒网-https://www.yangxingzhen.cn/7484.html

curl -u "admin:Harbor12345" -X POST -H "Content-Type: application/json" "http://172.168.1.249/api/projects" -d @createproject.json

createproject.json为文件名,文件内容参考createproject.json

# 0为私有

{

    "project_name": "项目名",

    "public": 0

}

# 创建用户

curl -u "admin:Harbor12345" -X POST -H "Content-Type: application/json" "http://172.168.1.249/api/users" -d @user.json

文件内容参考user.json

{

    "user_id": 5,

    "username": "test",

    "email": "test@qq.com",

    "password": "Harbor12345",

    "realname": "test",

    "role_id": 0

}

# 获取用户信息,除admin外

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/users"

# 查看当前用户信息

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/users/current"

# 删除用户,3是用户user_id

curl -u "admin:Harbor12345" -X DELETE -H "Content-Type: application/json" "http://172.168.1.249/api/users/34"

# 修改用户密码

curl -u "admin:Harbor12345" -X PUT -H "Content-Type: application/json" "http://172.168.1.249/api/users/4/password" -d @uppwd.json

# 查看项目相关角色

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/projects/2/members/"

# 项目添加角色

curl -u "jaymarco:Harbor123456" -X POST -H "Content-Type: application/json" "http://172.168.1.249/api/projects/2/members/" -d @role.json

# 查看镜像

curl -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/repositories?project_id=2&q=镜像名"

# 删除镜像

curl -u "admin:Harbor12345" -X DELETE -H "Content-Type: application/json" "http://172.168.1.249/api/repositories/marktrace%2Fasset/tags/latest"

# 获取镜像标签

curl -s -u "admin:Harbor12345" -X GET -H "Content-Type: application/json" "http://172.168.1.249/api/repositories/marktrace%2Fasset/tags/" |grep "digest" -C 2 |grep ""name""

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
我的微信
微信公众号
微信扫一扫,关注我!
weinxin
我的公众号
Docker最后更新:2022-11-25
小柒助手
  • 本文由 小柒助手 发表于 2020年8月21日15:32:14
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.cn/7484.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证