创建私有docker仓库
安装docker repo
yum -y install docker-registry
修改docker repo 配置
$ cat /etc/docker-distribution/registry/config.yml
version: 0.1
log:
fields:
service: registry
storage:
cache:
layerinfo: inmemory
filesystem:
rootdirectory: /var/lib/registry #镜像存储位置,可以修改成自己的
http:
addr: :5000 #监听端口为5000
启动docker
systemctl start docker-distribution
systemctl enable docker-distribution
上传docker images
docker tag mysql:5.7.22 <IP>:5000/mysql:5.7.22
docker push docker-registry:5000/mysql:5.7.22
##如果推送报错需要
$ vim /etc/docker/daemon.json
{
"registry-mirrors": ["docker-registry:5000"],
"insecure-registries": ["docker-registry:5000"]
}
##如果出现FATA[0000] Error response from daemon: v1 ping attempt failed with error: Get https://10.121.136.139:5000/v1/_ping: local error: record overflow. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 10.121.136.139:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/10.121.136.139:5000/ca.crt
$ vim /etc/default/docker
DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=10.121.136.139:5000"
$ systemctl restart docker
启动docker repo
docker run -d -p 5000:5000 --restart=always -v /var/ftp/Docker/:/var/lib/registry registry
获取docker repo中的images列表
curl http://10.121.136.139:5000/v2/_catalog
##列出images详情
curl -X GET http://10.121.136.139:5000/v2/ubuntu/tags/list
删除docker repo image
##### 方法一 #####
##delete_docker_registry_image 需要下载 wget https://raw.githubusercontent.com/burnettk/delete-docker-registry-image/master/delete_docker_registry_image.py | sudo tee /usr/local/bin/delete_docker_registry_image
export REGISTRY_DATA_DIR=/var/ftp/Docker/docker/registry/v2; delete_docker_registry_image --image ceph:1.3.1
##### 方法二 #####
# 获取hash
curl http://10.127.6.35:5000/v2/centos7.7/manifests/ceph_rpm_ok
# 删除images
curl -X DELETE http://10.127.6.35:5000/v2/centos7.7/manifests/sha256:ce5be5c4e5c651cf8e2b6ac8c749f37a2e73a85a00b04d87b2aa514ef963425e
###注意, 删除需要修改配置文件 /etc/docker-distribution/registry/config.yml
storage:
delete:
enabled: true
# 重启服务systemctl restart docker-distribution
harbor 管理iamges仓库
git clone https://github.com/goharbor/harbor.git