CentOS 7 搭建docker倉庫

docker已經足夠火了,試想每次部署都要飄洋過海去docker官方倉庫拉鏡像,肯定受不了,所以必須搭建內網私有docker倉庫,充分利用高速內網帶寬。


1、安裝docker

yum install docker

2、開啓docker服務

systemctl enable docker
systemctl start docker

3、獲取docker鏡像

docker pull centos

上面是從docker官方倉庫獲取centos鏡像,速度很慢。

也可以從別的地方獲取,比如

docker pull index.tenxcloud.com/tenxcloud/centos

4、安裝並啓用 docker-distribution

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、查看本地鏡像

docker images

示例輸出如下:

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


6、給本地docker鏡像打標籤

docker tag 6e7516266d96 localhost:5000/centos:latest

7、把鏡像發佈到倉庫中

docker push localhost:5000/centos:latest

8、刪除本地鏡像

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

9、從倉庫中獲取鏡像

docker pull localhost:5000/centos:latest

10、查看剛剛本地拉取的鏡像

docker images


11、修改docker配置文件,默認使用內網倉庫

修改文件/etc/sysconfig/docker

#添加內網倉庫
ADD_REGISTRY='--add-registry localhost:5000'
#禁用官方倉庫docker.io(可選)
BLOCK_REGISTRY='--block-registry docker.io'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章