利用docker registry搭建私有仓库(自签发证书+登陆认证)

我们在使用Docker时 下载镜像一般都是在外网下载并使用。可是当我们没有外网时,我们便自己搭建私有仓库。

1.利用registry镜像搭建私有仓库

1.配置阿里云镜像加速器

(1)访问阿里云并登陆
在这里插入图片描述
在这里插入图片描述
(2)获取镜像加速器
在这里插入图片描述
(3).配置镜像加速器

[root@foundation66 Desktop]# cd /etc/docker/
[root@foundation66 docker]# ls
certs.d  key.json
#1.修改配置文件
[root@foundation66 docker]# vim daemon.json
###########################
{
  "registry-mirrors": ["https://2izot27h.mirror.aliyuncs.com"]
}

在这里插入图片描述

#2.重载守护进程
[root@foundation66 docker]# systemctl daemon-reload
#3.重启docker服务
[root@foundation66 docker]# systemctl restart docker

2.从阿里云拉取registry镜像

[root@foundation66 ~]# docker pull registry

在这里插入图片描述

[root@foundation66 ~]# docker images

在这里插入图片描述
3.创建私有仓库(容器)

#1.创建私有仓库(容器),-d表示打入后台,-p表示端口映射,-v表示挂载数据卷
[root@foundation66 ~]# docker run -d --name registry -p 5000:5000 -v /opt/registry:/var/lib/registry registry
270b16b732b06ae4c6745a5873141dc7fe79c324ba54f11b86bf251bffbacb05
#2.查看容器
[root@foundation66 ~]# docker ps

在这里插入图片描述
测试:

1.上传自定义镜像到私有仓库

#1.查看镜像
[root@foundation66 ~]# docker images

在这里插入图片描述

#2.tag表示重命名
[root@foundation66 ~]# docker tag busybox:v1 localhost:5000/busybox:v1
[root@foundation66 docker]# docker images 
#3.上传镜像到私有仓库
[root@foundation66 ~]# docker push localhost:5000/busybox:v1

在这里插入图片描述

[root@foundation66 ~]# cd /opt/registry/
[root@foundation66 registry]# ls
docker
[root@foundation66 registry]# cd docker/
[root@foundation66 docker]# tree .
bash: tree: command not found...
[r
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值