歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習Linux

docker-5 docker倉庫,docker-5docker

docker-5 docker倉庫,docker-5docker

docker-5 docker倉庫,docker-5docker


docker部署環境:CentOS release 6.5 (Final)

Docker配置文件:/etc/sysconfig/docker  重要參數解釋:

-H 表示Docker Daemon綁定的地址 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:235

--registry-mirror表示Docker Registry的鏡像地址 --register-mirror=--registry-mirror=https://rr8hxwoy.mirror.aliyuncs.com  阿裡雲的一個加速節點

--selinux-enabled是否開啟Selinux    默認開啟 --selinux-enabled=true

--bip 表示網橋docker0使用指定CIDR網絡地址, --bip=172.17.42.1

1、編輯docker的配置文件,因為我們啟動的registry服務不是安全可信賴的。所以我們需要修改docker的配置文件,

[root@docker]# vim /etc/sysconfig/docker

other_args="--insecure-registry=192.168.1.243:5000 -H tcp://0.0.0.0:235 -H unix:///var/run/docker.sock"

2、修改好配置文件之後,重啟docker

[root@docker]# /etc/init.d/docker restart

3、獲取registry

[root@docker]# docker pull registry

4、啟動registry

[root@docker]# docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry registry

[root@docker]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e600f830f51 registry "/entrypoint.sh /etc 13 minutes ago Up 2 seconds 0.0.0.0:5000->5000/tcp drunk_albattani

Registry服務默認會將上傳的鏡像保存在容器的/var/lib/registry,我們將主機的/opt/registry目錄掛載到該目錄,即可實現將鏡像保存到主機的/opt/registry目錄了。

這時在浏覽器裡面輸入:http://IP:5000/v2/

會返回一個{}

5、做tag標簽

[root@AY121107032540ded7114 ROOT]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
pt/tomcat_biz       v1                  f56c998ac2f3        37 hours ago        756.3 MB
centos              latest              97cad5e16cb6        6 days ago          196.5 MB
registry            latest              5c929a8b587a        3 weeks ago         33.27 MB
[root@AY121107032540ded7114 ROOT]# docker tag centos:latest 10.116.208.166:5000/test/centos:v1     
[root@AY121107032540ded7114 ROOT]# docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
pt/tomcat_biz                     v1                  f56c998ac2f3        37 hours ago        756.3 MB
centos                            latest              97cad5e16cb6        6 days ago          196.5 MB
10.116.208.166:5000/test/centos   v1                  97cad5e16cb6        6 days ago          196.5 MB
registry                          latest              5c929a8b587a        3 weeks ago         33.27 MB

6、push到registry

[root@AY121107032540ded7114 ROOT]# docker push 10.116.208.166:5000/test/centos:v1
The push refers to a repository [10.116.208.166:5000/test/centos] (len: 1)
97cad5e16cb6: Image already exists 
05fe84bf6d3f: Image already exists 
af0819ed1fac: Image successfully pushed 
3690474eb5b4: Image already exists 
Digest: sha256:31879c6c05e2cb19300a12a685998f4d45f924f48a7d7d215846c9511f40176c

7、打開另外一台服務器,做pull測試

[root@AY121107032540ded7114 ROOT]# docker push 10.116.208.166:5000/test/centos:v1

到此為止,私有的倉庫就搭建好了。

 

http://xxxxxx/Linuxjc/1171552.html TechArticle

Copyright © Linux教程網 All Rights Reserved