参考官方文档地址
地址:https://hub.docker.com/_/registry
https://hub.docker.com/_/registry
文件非常简单,关键如下:
搭建相关命令
搭建私服
# 创建docker私服镜像
docker run -d -p 5000:5000 --restart always --name registry registry:2
#查看所有镜像
docker images
#下载一个centos7的镜像
docker pull centos:7
#修改一个镜像的名称
docker tag docker.io/centos:7 localhost:5000/chen/centos:example
相关http命令
#推送镜像到本地仓库
docker push localhost:5000/chen/centos:example
#查看本地仓库依赖
[root@VM-16-7-centos ~]# curl http://localhost:5000/v2/_catalog
{"repositories":["chen/registry"]}
#查看本地仓库依赖以及版本
[root@VM-16-7-centos ~]# curl http://localhost:5000/v2/chen/centos/tags/list
{"name":"chen/centos","tags":["example"]}
拉取镜像
#删除本地镜像
docker rmi imagesId -f
#从仓库中拉取镜像
docker pull localhost:5000/chen/centos:example
远程访问docker仓库
需要修改在 /etc/docker/的daemon.json文件,
把docker pull和push的https的请求改为http的请求
{
"registry-mirror": [
"https://registry.docker-cn.com"
],
"insecure-registries": [
"ip:port"
]
}
镜像存放位置
#使用命令
docker exec -it docker exec -it registry /bin/sh
# 镜像位置在
/var/lib/registry/