CentOS 7 搭建docker仓库

docker已经足够火了,试想每次部署都要飘洋过海去docker官方仓库拉镜像,肯定受不了,所以必须搭建内网私有docker仓库,充分利用高速内网带宽。


1、安装docker

1
yum install docker

2、开启docker服务

1
2
systemctl enable docker
systemctl start docker

3、获取docker镜像

1
docker pull centos

上面是从docker官方仓库获取centos镜像,速度很慢。

也可以从别的地方获取,比如

1
docker pull index.tenxcloud.com/tenxcloud/centos

4、安装并启用 docker-distribution

1
2
3
yum install docker-distribution
systemctl enable docker-distribution
systemctl start docker-distribution

可以根据需要修改docker-distribution的配置文件 /etc/docker-distribution/registry/config.yml

比如端口(默认5000),镜像存储路径(默认/var/lib/registry)


5、查看本地镜像

1
docker images

示例输出如下:

1
2
3
# docker images
REPOSITORY                   TAG   IMAGE ID     CREATED     SIZE
index.tenxcloud.com/tenxcloud/centos  latest 6e7516266d96  9 months ago  309.9 MB


6、给本地docker镜像打标签

1
docker tag 6e7516266d96 localhost:5000/centos:latest

7、把镜像发布到仓库中

1
docker push localhost:5000/centos:latest

8、删除本地镜像

1
2
3
docker rmi index.tenxcloud.com/tenxcloud/centos
docker rmi localhost:5000/centos
docker images

9、从仓库中获取镜像

1
docker pull localhost:5000/centos:latest

10、查看刚刚本地拉取的镜像

1
docker images


11、修改docker配置文件,默认使用内网仓库

修改文件/etc/sysconfig/docker

1
2
3
4
#添加内网仓库
ADD_REGISTRY='--add-registry localhost:5000'
#禁用官方仓库docker.io(可选)
BLOCK_REGISTRY='--block-registry docker.io'










本文转自 紫色葡萄 51CTO博客,原文链接:http://blog.51cto.com/purplegrape/1897400,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值