二进制安装registry

下载registry包

curl -LO https://github.com/distribution/distribution/releases/download/v2.8.3/registry_2.8.3_linux_amd64.tar.gz

创建安装目录

sudo mkdir -p /app/registry/data
sudo chown -R ${USER}. /app/registry/data

配置文件

cat <<'EOF' | sudo tee /app/registry/config.yml > /dev/null
version: 0.1
log:
  level: info
  formatter: json
  fields:
    service: registry
storage:
  # 使用本地磁盘存储镜像文件
  filesystem:
    rootdirectory: /app/registry/data
  # 缓存在存储后端访问的数据
  cache:
    blobdescriptor: inmemory
  # 允许调接口删除镜像
  delete:
    enabled: true
http:
  addr: :5000
  headers:
    # 建议设置。当浏览器被指示从 registry 加载页面时,它们就不会将内容解释为HTML
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3
EOF

systemd文件

cat <<'EOF' | sudo tee /usr/lib/systemd/system/registry.service > /dev/null
[Unit]
Description=Docker Registry
Documentation=https://github.com/distribution/distribution
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=simple
User=ops
ExecStart=/usr/local/bin/registry serve /app/registry/config.yml
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
EOF

启动registry

sudo systemctl daemon-reload
sudo systemctl enable registry --now

API接口

  1. 查看仓库列表
GET /v2/_catalog

curl -s localhost:5000/v2/_catalog | python -m json.tool
  1. 查看镜像有哪些版本号
GET /v2/<name>/tags/list

curl -s localhost:5000/v2/k8s/pause/tags/list | python -m json.tool
  1. 查看digest信息
GET /v2/<name>/manifests/<reference>

curl -s -H "Accept:application/vnd.docker.distribution.manifest.v2+json" localhost:5000/v2/k8s/pause/manifests/3.6 | python -m json.tool

.config.digest 字段里面记录

  1. 删除镜像
DELETE /v2/<name>/manifests/<reference>

curl -X DELETE localhost:5000/v2/k8s/pause/manifests/sha256:6270bb605e12e581514ada5fd5b3216f727db55dc87d5889c790e4c760683fee

在线文档:https://distribution.github.io/distribution/spec/api/

posted @   jiaxzeng  阅读(109)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示