docker在阿里云,distribution和registry管理个人镜像仓库

目录

一.阿里云

1.登录进入阿里云网站,点击个人实例进行创建

2.创建仓库,填写相关信息

3.在访问凭证中设置固定密码用于登录,登录时用户名是使用你注册阿里云的账号名称,密码使用设置的固定密码

4.为镜像打标签并推送到仓库

5.拉取镜像验证

二.distribution

1.扩展源下载docker-distribution并启动

2.打标签并认证安全仓库

3.推送到私人仓库

4.拉取镜像

三.registry

1.拉取registry的镜像

2.运行容器并打标签

3.认证安全仓库

4.推送到私人仓库

5.拉取镜像


一.阿里云

1.登录进入阿里云网站,点击个人实例进行创建

阿里云登录 - 欢迎登录阿里云,安全稳定的云计算服务平台

d535c640d9f24daab61708a6eaf0fd96.png

2.创建仓库,填写相关信息

选择公共,私有在拉取镜像时需要登录

34571d43373743bc83040c8ae7de6d7b.png

选择本地仓库 

c6d2916681f64caea0cabd2593a5c4f2.png 创建完成

1ef86536128c48029b02604e253c8106.png

ec7140a9cff14e249340312b2ce9cad4.png

3.在访问凭证中设置固定密码用于登录,登录时用户名是使用你注册阿里云的账号名称,密码使用设置的固定密码

49f5eea7bc84427f8a1ed5261123f4d4.png

[root@localhost ~]# docker login --username=aliyun783xxxxxxx registry.cn-hangzhou.aliyuncs.com
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

4.为镜像打标签并推送到仓库

[root@localhost ~]# docker tag mysql:5.6 registry.cn-hangzhou.aliyuncs.com/su03/mycontainer:mysql_5.6  #这个地址在仓库信息页面直接复制
[root@localhost ~]# docker push registry.cn-hangzhou.aliyuncs.com/su03/mycontainer:mysql_5.6 
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/su03/mycontainer]
7137327a7221: Pushed 
49a1ca1cd2b8: Pushed 
7c5a5c1986b1: Pushed 
eba393347f89: Pushed 
2612088e90f6: Pushed 
e3dce1c82d4e: Pushed 
7ea96a4e341b: Pushed 
4085e588967d: Pushed 
d414fdead0b9: Pushed 
2e1029557391: Pushed 
2b83e5699838: Pushed 
mysql_5.6: digest: sha256:897086d07d1efa876224b147397ea8d3147e61dd84dce963aace1d5e9dc2802d size: 2621

5.拉取镜像验证

[root@localhost ~]# docker pull registry.cn-hangzhou.aliyuncs.com/su03/mycontainer:mysql_5.6
mysql_5.6: Pulling from su03/mycontainer
Digest: sha256:897086d07d1efa876224b147397ea8d3147e61dd84dce963aace1d5e9dc2802d
Status: Image is up to date for registry.cn-hangzhou.aliyuncs.com/su03/mycontainer:mysql_5.6
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer:mysql_5.6
[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB
[root@localhost ~]# docker run -it --name alimysql registry.cn-hangzhou.aliyuncs.com/su03/mycontainer:mysql_5.6 ls /
bin  boot  dev	docker-entrypoint-initdb.d  entrypoint.sh  etc	home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

二.distribution

1.扩展源下载docker-distribution并启动

[root@localhost ~]# yum info docker-distribution

[root@localhost ~]# yum install -y docker-distribution.x86_64

[root@localhost ~]# systemctl start docker-distribution

[root@localhost ~]# cd /etc/docker-distribution/registry/

[root@localhost registry]# cat config.yml 
version: 0.1
log:
  fields:
    service: registry
storage:
    cache:
        layerinfo: inmemory
    filesystem:
        rootdirectory: /var/lib/registry  #默认的镜像存放大致路径
http:
    addr: :5000   #端口

2.打标签并认证安全仓库

[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
centos                                               latest      5d0da3dc9764   23 months ago   231MB
registry                                             2.6.2       10b45af23ff3   3 years ago     28.5MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB

[root@localhost ~]# docker tag centos:latest 192.168.2.190:5000/centos:latest

[root@localhost ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["192.168.2.190:5000"]
}

[root@localhost ~]# systemctl restart docker

3.推送到私人仓库

[root@localhost ~]# docker push 192.168.2.190:5000/centos:latest 
The push refers to repository [192.168.2.190:5000/centos]
74ddd0ec08fa: Pushed 
latest: digest: sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc size: 529

[root@localhost ~]# ll /var/lib/registry/docker/registry/v2/repositories
total 0
drwxr-xr-x 5 root root 55 Aug 25 17:30 centos

4.拉取镜像

[root@localhost ~]# docker pull 192.168.2.190:5000/centos:latest 
latest: Pulling from centos
Digest: sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc
Status: Image is up to date for 192.168.2.190:5000/centos:latest
192.168.2.190:5000/centos:latest

[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
192.168.2.190:5000/centos                            latest      5d0da3dc9764   23 months ago   231MB
centos                                               latest      5d0da3dc9764   23 months ago   231MB
registry                                             2.6.2       10b45af23ff3   3 years ago     28.5MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB

三.registry

1.拉取registry的镜像

[root@localhost ~]# systemctl stop docker-distribution.service 

[root@localhost ~]# docker pull registry:2.6.2

2.运行容器并打标签

-v指定把镜像存储到宿主机的/registry目录下

[root@localhost ~]# docker run -itd --name myregistry -p 5000:5000 -v /registry:/var/lib/registry registry:2.6.2 
a2ddb1f22601398d13dcfcc2f6e495883d5b9cf52fce690eefbe8d0cfc787fd0

[root@localhost ~]# docker tag nginx:latest 192.168.2.190:5000/nginx:latest

3.认证安全仓库

[root@localhost ~]# vim /etc/docker/daemon.json 
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["192.168.2.190:5000"]
}

[root@localhost ~]# systemctl restart docker

4.推送到私人仓库

[root@localhost ~]# docker push 192.168.2.190:5000/nginx:latest 
The push refers to repository [192.168.2.190:5000/nginx]
563c64030925: Pushed 
6fb960878295: Pushed 
e161c3f476b5: Pushed 
8a7e12012e6f: Pushed 
d0a62f56ef41: Pushed 
4713cb24eeff: Pushed 
511780f88f80: Pushed 
latest: digest: sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35 size: 1778

[root@localhost ~]# ll /registry/docker/registry/v2/repositories/
total 0
drwxr-xr-x 5 root root 55 Aug 25 18:09 nginx

5.拉取镜像

[root@localhost ~]# docker pull 192.168.2.190:5000/nginx:latest 
latest: Pulling from nginx
Digest: sha256:48a84a0728cab8ac558f48796f901f6d31d287101bc8b317683678125e0d2d35
Status: Image is up to date for 192.168.2.190:5000/nginx:latest
192.168.2.190:5000/nginx:latest

[root@localhost ~]# docker images
REPOSITORY                                           TAG         IMAGE ID       CREATED         SIZE
192.168.2.190:5000/nginx                             latest      eea7b3dcba7e   9 days ago      187MB
nginx                                                latest      eea7b3dcba7e   9 days ago      187MB
mysql                                                5.6         dd3b2a5dcb48   20 months ago   303MB
registry.cn-hangzhou.aliyuncs.com/su03/mycontainer   mysql_5.6   dd3b2a5dcb48   20 months ago   303MB
192.168.2.190:5000/centos                            latest      5d0da3dc9764   23 months ago   231MB
centos                                               latest      5d0da3dc9764   23 months ago   231MB
registry                                             2.6.2       10b45af23ff3   3 years ago     28.5MB
owncloud                                             latest      327bd201c5fb   4 years ago     618MB
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

树下一少年

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

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

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

打赏作者

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

抵扣说明:

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

余额充值