摘要
本文部分内容来源于网络,大部分内容原创
由于最近在做一个docker迁移项目,原环境是一套买来的,现在不用了,所以乘着这个机会就整个环境重新搭建了,网上找了一堆乱七八糟的文档,看着都不太一样,最终整合了一下,经过自己的测试,终于调通了。
安装docker
1 | apt update && apt upgrade |
重建docker0网桥
1 | apt-get install bridge-utils |
下载docker registry 镜像
1 | docker pull registry |
registry 测试
启动测试
1 | docker run -d -p 5000:5000 \ |
推送验证
1 | docker tag alpine 172.16.7.3:5000/myalpine |
带验证的registry
创建本地目录
1 | mkdir -p /data/registry/{registry,conf,auth} |
生成用户和密码
1 | cd /data/registry/auth |
创建配置文件
1 |
|
启动命令
1 | docker run -d -p 5000:5000 \ |
验证测试
1 | docker login http://172.16.7.3:5000 |
给registry添加nginx+https代理验证
编译安装nginx1.9.15、创建ngxin启动文件、创建nginx配置文件请参照另一篇文章
nginx1.9.15 编译安装
制作ca证书
1 | cd /usr/local/nginx/conf/ssl |
生成服务端证书并用ca证书认证
1 |
|
生成验证文件
1 | htpasswd -c conf/.htpasswd httx |
创建虚拟主机
1 | vim conf/vhosts/opreg.conf |
client 配置
将自签ca证书发送到客户端
1 | mkdir -p /etc/docker/certs.d/opreg.chinawayltd.com/ |
docker api
以下关于docker registry api 的内容取自(http://blog.csdn.net/ztsinghua/article/details/51496658)
docker registry v2版本的http api 一直没有找到合适的,自己通过阅读官方文档整理了一下。
概要
method | path | Entity | Description |
---|---|---|---|
GET | /v2/ | Base | Check that the endpoint implements Docker Registry API V2. |
GET | /v2/ |
Tags | Fetch the tags under the repository identified by name. |
GET | /v2/ |
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/ |
Manifest | Put the manifest identified by nameand referencewhere referencecan be a tag or digest. |
DELETE | /v2/ |
Manifest | Delete the manifest identified by nameand reference. Note that a manifest can only be deleted by digest. |
GET | /v2/ |
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/ |
Blob | Delete the blob identified by nameand digest |
POST | /v2/ |
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/ |
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/ |
Blob Upload | Upload a chunk of data for the specified upload. |
PUT | /v2/ |
Blob Upload | Complete the upload specified by uuid, optionally appending the body as the final chunk. |
DELETE | /v2/ |
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. |
专有名词解释
1 | repository name(存储库名称) |