docker 创建私有仓库-registry

###设置私有仓库 registry
一、创建docker
1.设置防火墙

iptables -I INPUT 1 -p tcp --dport 5000 -j ACCEPT

 2. 添加软件源信息

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3. 更新并安装 Docker-CE

sudo yum makecache fast
sudo yum -y install docker-ce

4. 开启Docker服务

systemctl start docker && systemctl enable docker 

##docker info 查看信息
 docker info
5. ###添加自定义仓库加速器

cat<<END>/etc/docker/daemon.json
{
"registry-mirrors":["https://vaflkxbk.mirror.aliyuncs.com"]
}
END

6. 重启服务                                                                                                                                                   

systemctl daemon-reload && systemctl restart docker && docker info ##确定 自定义仓库添加

二、创建仓库
##7. 创建私有创库仓库   

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

##8.测试

docker pull ningx
docker tag nginx 192.168.97.208:5000/nginx   
docker push 192.168.97.208:5000/nginx

###报错如下

unable to ping registry endpoint https://192.168.97.208:5000/v0/
v2 ping attempt failed with error: Get https://192.168.97.208:5000/v2/: http: server gave HTTP response to HTTPS client

###在daemon.json 中添加如下

vi /etc/docker/daemon.json
{
"registry-mirrors":["https://vaflkxbk.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.97.208:5000"]
} 

###再次测试

docker push 192.168.97.208:5000/nginx
The push refers to repository [192.168.97.208:5000/nginx]
3ff93588120e: Pushed
24ee0a3fd4b9: Pushed
d626a8ad97a1: Pushed
latest: digest: sha256:1f9c00b4c95ef931afa097823d902e7602aebc3ec5532e907e066978075ca3e0 size: 948

###查看仓库源,共三个

docker info

Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 192.168.97.208:5000
 127.0.0.0/8
Registry Mirrors:
 https://vaflkxbk.mirror.aliyuncs.com/
Live Restore Enabled: false

 

 

 

阅读更多
个人分类: Kubernetes
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭