ralph的云计算之路--- docker篇章07--Docker仓库

Docke 仓库

在公有仓库上传、下载、搜索 images
1.先要到 www.docker.com 或 https://hub.docker.com/上注册账户
在这里插入图片描述
2.终端中登录你注册的账户
[root@zx~]# docker login
Username: 你创建的用户
Password: 你的密码
Login Succeeded

  1. 上传你自己的镜像到云上
[root@zx~]# docker ps
[root@zx ~]# docker commit 1ad15487827f wangjiadee/test
[root@zx~]# docker push wangjiadee/test

我注册的用户名为 wangjiadee 所以我的仓库名也就是 wangjiadee,后面的 test 是我的镜像名
等上传成功后,你就可以在 www.docker.com 中登录你的账户,可以看到你上传的镜像了
在别的电脑执行 docker pull wjli/test
就可以很方便的把你上传的镜像下载下来使用


代码解释:

  1. 先pull下一个镜像 busybox 因为比较小 适合做实验
  2. 然后在打一个标签
  3. 上传到公共仓库去
  4. 接着你可以在https://hub.docker.com 去查看
    在这里插入图片描述5.然后在本地删除原来的镜像
    6.在下载新的你的仓库的镜像
[root@localhost ~]# docker pull busybox
[root@localhost ~]# docker tag busybox:latest wangjiadee/busybox:v1
[root@localhost ~]# docker push wangjiadee/busybox
The push refers to repository [docker.io/wangjiadee/busybox]
6c0ea40aef9d: Layer already exists 
v1: digest: sha256:dd97a3fe6d721c5cf03abac0f50e2848dc583f7c4e41bf39102ceb42edfd1808 size: 527

[root@localhost ~]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
<none>                    <none>              99acf599b3d0        21 minutes ago      366MB
<none>                    <none>              e556ef1934a3        21 minutes ago      408MB
centos                    httpd               5793f9249cc7        56 minutes ago      303MB
ralph/nginx               latest              8eed31b6faa7        6 hours ago         126MB
richarvey/nginx-php-fpm   latest              bb49f1636b1a        7 days ago          444MB
nginx                     latest              ab56bba91343        12 days ago         126MB
nginx                     latest              ab56bba91343        12 days ago         126MB
php                       latest              d1d1e483ba07        12 days ago         401MB
mysql                     5.7                 383867b75fd2        12 days ago         373MB
mysql                     latest              b8fd9553f1f0        12 days ago         445MB
busybox                   latest              19485c79a9bb        2 weeks ago         1.22MB
wangjiadee/busybox        v1                  19485c79a9bb        2 weeks ago         1.22MB
centos                    7                   67fa590cfc1c        4 weeks ago         202MB
centos                    latest              67fa590cfc1c        4 weeks ago         202MB
centos                    latest              67fa590cfc1c        4 weeks ago         202MB
[root@localhost ~]# docker rmi wangjiadee/busybox:v1 
[root@localhost ~]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
<none>                    <none>              99acf599b3d0        22 minutes ago      366MB
<none>                    <none>              e556ef1934a3        22 minutes ago      408MB
centos                    httpd               5793f9249cc7        57 minutes ago      303MB
ralph/nginx               latest              8eed31b6faa7        6 hours ago         126MB
richarvey/nginx-php-fpm   latest              bb49f1636b1a        7 days ago          444MB
nginx                     latest              ab56bba91343        12 days ago         126MB
nginx                     latest              ab56bba91343        12 days ago         126MB
php                       latest              d1d1e483ba07        12 days ago         401MB
mysql                     5.7                 383867b75fd2        12 days ago         373MB
mysql                     latest              b8fd9553f1f0        12 days ago         445MB
busybox                   latest              19485c79a9bb        2 weeks ago         1.22MB
centos                    7                   67fa590cfc1c        4 weeks ago         202MB
centos                    latest              67fa590cfc1c        4 weeks ago         202MB
centos                    latest              67fa590cfc1c        4 weeks ago         202MB
[root@localhost ~]# docker pull wangjiadee/busybox:v1
v1: Pulling from wangjiadee/busybox
[DEPRECATION NOTICE] registry v2 schema1 support will be removed in an upcoming release. Please contact admins of the docker.io registry NOW to avoid future disruption.
7c9d20b9b6cd: Already exists 
Digest: sha256:7266973cc4c237277b6dad0158e3d37485a99225b80506ed03eb56b5cdf16263
Status: Downloaded newer image for wangjiadee/busybox:v1
docker.io/wangjiadee/busybox:v1
[root@localhost ~]# docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
<none>                    <none>              99acf599b3d0        22 minutes ago      366MB
<none>                    <none>              e556ef1934a3        23 minutes ago      408MB
centos                    httpd               5793f9249cc7        58 minutes ago      303MB
ralph/nginx               latest              8eed31b6faa7        6 hours ago         126MB
richarvey/nginx-php-fpm   latest              bb49f1636b1a        7 days ago          444MB
nginx                     latest              ab56bba91343        12 days ago         126MB
nginx                     latest              ab56bba91343        12 days ago         126MB
php                       latest              d1d1e483ba07        12 days ago         401MB
mysql                     5.7                 383867b75fd2        12 days ago         373MB
mysql                     latest              b8fd9553f1f0        12 days ago         445MB
wangjiadee/busybox        v1                  19485c79a9bb        2 weeks ago         1.22MB
busybox                   latest              19485c79a9bb        2 weeks ago         1.22MB
centos                    7                   67fa590cfc1c        4 weeks ago         202MB
centos                    latest              67fa590cfc1c        4 weeks ago         202MB
centos                    latest              67fa590cfc1c        4 weeks ago         202MB

在私有仓库上传、下载、搜索 images

  1. 在另一台机上创建私有仓库(192.168.28.202)
    Docker Hub 作为 Docker 默认官方公共镜像;如果想自己搭建私有镜像仓库,官方也
    提供 registry 镜像,使得搭建私有仓库非常简单。
    下载 registry 镜像并启动
    #docker pull registry
    #docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always
    –name registry registry
      测试,查看镜像仓库中所有镜像
    #curl http://192.168.28.202:5000/v2/_catalog
    {“repositories”:[]}
  2. 在 192.168.28.161 上配置使用私有仓库
    1)配置私有仓库可信任
    #vi /etc/docker/daemon.json
    {
    “registry-mirrors”: [ “https://registry.docker-cn.com”],
    “insecure-registries”: [“192.168.28.202:5000”]
    }
    #systemctl restart docke2、打标签
    #docker tag centos:httpd 192.168.28.202:5000/centos-httpd:v2
    3、上传
    #docker push 192.168.28.202:5000/centos-httpd:v2
    4、下载
    #docker pull 192.168.28.202:5000/centos-httpd:v2
    5、列出镜像标签
    #curl http://192.168.28.202:5000/v2/centos-httpd/tags/list
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值