• docker 为我们提供了一个快速搭建私有仓库的镜像

    docker pull docker.io/registry
    
  • 启动

    docker run -d -v ./registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
    docker run -d -v ./registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
    

-d 后台运行 -v 文件夹映射<本地:远程> -p 端口映射<本地:远程>

  • 编译 docker build . -t basic-registry.default.svc.cluster.local:5000/yuke/blindbox:0.0.6

会自动以当前目录下的Dockerfile文件进行打包生成镜像

  • 为镜像添加标签 docker tag ubuntu:15.10 dchub:5000/ubuntu:20201203

dchub 可以直接用IP地址替换

以上将 ubuntu:15.10 镜像归类为 dchub:5000/ubuntu:v3

在hosts文件中为dchub添加IP指向

  • 推送 docker push dchub:5000/ubuntu:20201203

推送过程,如果出现Get https://dchub:5000/v1/_ping: http: server gave HTTP response to HTTPS client,则需要修改vim /etc/docker/daemon.json文件

{
	"insecure-registries":["dchub:5000"],
}

registry 相关API

| method | path | Entity | Description| | ---- | ---- | ---- | ---- | |GET| /v2/| Base| Check that the endpoint implements Docker Registry API V2. |GET| /v2//tags/list| Tags| Fetch the tags under the repository identified by name. |GET| /v2//manifests/| Manifest| Fetch the manifest identified by nameand referencewhere referencecan be a tag or digest. A HEADrequest can also be issued to this endpoint to obtain resource information without receiving all data. |PUT| /v2//manifests/| Manifest| Put the manifest identified by nameand referencewhere referencecan be a tag or digest. |DELETE| /v2//manifests/| Manifest| Delete the manifest identified by nameand reference. Note that a manifest can only be deleted by digest. |GET| /v2//blobs/| Blob| Retrieve the blob from the registry identified bydigest. A HEADrequest can also be issued to this endpoint to obtain resource information without receiving all data. |DELETE| /v2//blobs/| Blob| Delete the blob identified by nameand digest |POST| /v2//blobs/uploads/| Initiate Blob Upload| Initiate a resumable blob upload. If successful, an upload location will be provided to complete the upload. Optionally, if thedigest parameter is present, the request body will be used to complete the upload in a single request. |GET |/v2//blobs/uploads/| Blob Upload| Retrieve status of upload identified byuuid. The primary purpose of this endpoint is to resolve the current status of a resumable upload. |PATCH |/v2//blobs/uploads/| Blob Upload |Upload a chunk of data for the specified upload. |PUT |/v2//blobs/uploads/| Blob Upload| Complete the upload specified by uuid, optionally appending the body as the final chunk. |DELETE |/v2//blobs/uploads/| Blob Upload| Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout. |GET |/v2/_catalog| Catalog |Retrieve a sorted, json list of repositories available in the registry.

扩展

  • harbo