docker学习(十)安装registry镜像仓库


前言

可以使用registry镜像来搭建私有镜像仓库,将公司项目打成镜像后上传到私有镜像仓库中,在局域网内实现共享。


一、安装

1、下载镜像

[root@k8s-master ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
79e9f2f55bf5: Pull complete 
0d96da54f60b: Pull complete 
5b27040df4a2: Pull complete 
e2ead8259a04: Pull complete 
3790aef225b9: Pull complete 
Digest: sha256:169211e20e2f2d5d115674681eb79d21a217b296b43374b8e39f97fcf866b375
Status: Downloaded newer image for registry:latest

2、查看镜像

[root@k8s-master ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
registry            latest              b8604a3fe854        3 weeks ago         26.2MB

3、启动容器

[root@k8s-master ~]# docker run -d --name=registry-custom -v /data/registry-data:/var/lib/registry -p 80:5000 registry:latest
9142c9c742c42390d90513c3f798c4b0f77c18924350f759b7f7696f70422b32

4、查看容器

[root@k8s-master ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
9142c9c742c4        registry:latest     "/entrypoint.sh /etc…"   28 seconds ago      Up 25 seconds       0.0.0.0:80->5000/tcp   registry-custom

二、测试

1、下载nginx镜像

[root@k8s-master ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
e5ae68f74026: Pull complete 
21e0df283cd6: Pull complete 
ed835de16acd: Pull complete 
881ff011f1c9: Pull complete 
77700c52c969: Pull complete 
44be98c0fab6: Pull complete 
Digest: sha256:9522864dd661dcadfd9958f9e0de192a1fdda2c162a35668ab6ac42b465f0603
Status: Downloaded newer image for nginx:latest

2、镜像打tag

docker tag nginx:latest 172.16.10.151:80/nginx:latest

3、push镜像

[root@k8s-master ~]# docker push 172.16.10.151:80/nginx:latest
The push refers to repository [172.16.10.151:80/nginx]
2bed47a66c07: Pushed 
82caad489ad7: Pushed 
d3e1dca44e82: Pushed 
c9fcd9c6ced8: Pushed 
0664b7821b60: Pushed 
9321ff862abb: Pushed 
latest: digest: sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47 size: 1570

4、在另一台机器上下载镜像

(1)配置daemon.json

[root@k8s-node02 ~]# cat /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver= cgroupfs"],
  "insecure-registries":["172.16.10.151:80"]
}

(2)重启docker

systemctl restart docker

(3)下载镜像

[root@k8s-node02 ~]# docker pull 172.16.10.151:80/nginx:latest
latest: Pulling from nginx
e5ae68f74026: Pull complete 
21e0df283cd6: Pull complete 
ed835de16acd: Pull complete 
881ff011f1c9: Pull complete 
77700c52c969: Pull complete 
44be98c0fab6: Pull complete 
Digest: sha256:4424e31f2c366108433ecca7890ad527b243361577180dfd9a5bb36e828abf47
Status: Downloaded newer image for 172.16.10.151:80/nginx:latest
172.16.10.151:80/nginx:latest

(4)查看下载镜像

[root@k8s-node02 ~]# docker images
REPOSITORY               TAG       IMAGE ID       CREATED      SIZE
172.16.10.151:80/nginx   latest    f652ca386ed1   2 days ago   141MB

三、http接口

查看镜像列表

[root@k8s-master ~]# curl http://127.0.0.1:80/v2/_catalog
{"repositories":["nginx"]}

查看镜像tag

[root@k8s-master ~]# curl http://127.0.0.1:80/v2/nginx/tags/list
{"name":"nginx","tags":["latest"]}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_lrs

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值