【docker】通过仓库共享镜像

通过仓库共享镜像

本地仓库

在本地建一个仓库,可以上传和下载做好的docker镜像。

用 git 下载源码后修改配置文件 config.yml,把 storage_path 部分改成 Docker 镜像仓库的存放地点:

$ git clone https://github.com/dotcloud/docker-registry.git
$ cd docker-registry
$ cp config_sample.yml config.yml
$ vi config.yml
...
# this is the default configuration when no flavor id specified
dev:
    storage: local
    storage_path: /home/vpsee/registry
    loglevel: debug
...

$ mkdir /home/vpsee/registry
$ pip install -r requirements.txt
$ gunicorn --access-logfile - --log-level debug --debug -b 0.0.0.0:5000 -w 1 wsgi:application
或者$ gunicorn --access-logfile - --debug -k gevent -b 0.0.0.0:80 -w 1 wsgi:application

打开浏览器,访问 IP 地址就可以看到 docker-registry 私有仓库在运行了。

查看一下系统已经有了哪些镜像

$ sudo docker images
REPOSITORY      TAG        ID              CREATED         SIZE
vpsee/ubuntu    latest     936a54e8a345    2 weeks ago     12.29 kB (virtual 327.8 MB)
ubuntu          latest     8dbd9e392a96    6 months ago    131.5 MB (virtual 131.5 MB)

我们打算把 vpsee/ubuntu 这个镜像(ID 是 936a54e8a345)上传(push)到我们刚创建的私有仓库里(这个私有仓库的 IP 地址是 192.168.2.45),会看到提示 Username/Password,初次 push 的话,可以自己设置用户名和密码:

$ sudo docker tag 936a54e8a345 192.168.2.45/vpsee
$ sudo docker push 192.168.2.45/vpsee
Username: vpsee
Password:
Email: docker@vpsee.com
Account created. Please use the confirmation link we sent to your e-mail to activate it.
The push refers to a repository [192.168.2.45/vpsee] (len: 1)
Processing checksums
Sending image list
Pushing repository 192.168.2.45/vpsee (1 tags)
Pushing 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c
Buffering to disk 58266504/? (n/a)
Pushing 58.27 MB/58.27 MB (100%)

完成 push 后,我们的私有仓库就有了第一个镜像了:


$ sudo docker images
REPOSITORY          TAG      ID             CREATED        SIZE
vpsee/ubuntu        latest   936a54e8a345   2 weeks ago    12.29 kB (virtual 327.8 MB)
ubuntu              latest   8dbd9e392a96   6 months ago   131.5 MB (virtual 131.5 MB)
ubuntu              precise  8dbd9e392a96   6 months ago   131.5 MB (virtual 131.5 MB)

以后只要 docker pull 192.168.2.45/vpsee 就可以从我们自己的私有仓库下载和运行镜像了,本地网络速度当然会快很多。

公共仓库

在docker 的index上创建用户,供上传和下载镜像。

转载于:https://blog.51cto.com/4951326/2097365

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值