docker仓库harbor搭建
1、安装docker-compose
1 [root@docker02 ~]# yum install epel-release 2 [root@docker02 ~]# pip install docker-compose
2、安装harbor
harbor下载地址
https://github.com/vmware/harbor/releases
1 [root@docker02 ~]# mv harbor-offline-installer-0.5.0.tgz /opt/ 2 [root@docker02 opt]# tar zxvf harbor-offline-installer-0.5.0.tgz 3 [root@docker02 harbor]# vim harbor.cfg 4 ## Configuration file of Harbor 5 #The IP address or hostname to access admin UI and registry service. 6 #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. 7 hostname = 172.16.138.101 修改hostname 8 #The protocol for accessing the UI and token/notification service, by default it is http. 9 #It can be set to https if ssl is enabled on nginx. 10 ui_url_protocol = http 11 #Email account settings for sending out password resetting emails. 12 #Email server uses the given username and password to authenticate on TLS connections to host and act as identity. 13 #Identity left blank to act as username. 14 email_identity = 15 email_server = smtp.mydomain.com
3、使用docker节点push 镜像到harbor
修改docker仓库地址
1 [root@docker03 images]# vim /etc/sysconfig/docker 2 .... 3 # If you want to add your own registry to be used for docker search and docker 4 # pull use the ADD_REGISTRY option to list a set of registries, each prepended 5 # with --add-registry flag. The first registry added will be the first registry 6 # searched. 7 ADD_REGISTRY='--add-registry harbor.suixingpay.com' 8 # If you want to block registries from being used, uncomment the BLOCK_REGISTRY 9 # option and give it a set of registries, each prepended with --block-registry 10 # flag. For example adding docker.io will stop users from downloading images 11 # from docker.io 12 # BLOCK_REGISTRY='--block-registry' 13 # If you have a registry secured with https but do not have proper certs 14 # distributed, you can tell docker to not look for full authorization by 15 # adding the registry to the INSECURE_REGISTRY line and uncommenting it. 16 INSECURE_REGISTRY='--insecure-registry harbor.suixingpay.com' 17 # On an SELinux system, if you remove the --selinux-enabled option, you 18 .....
重启docker服务
1 [root@docker03 images]# systemctl restart docker.service
登录Harbor(密码:Harbor12345)
1 [root@docker03 images]# docker login harbor.suixingpay.com 2 Username: admin 3 Password: 4 Login Succeeded
导入镜像
1 [root@docker03 images]# docker load -i heapster_grafana_v2.6.0-2.tar 2 78dbfa5b7cbc: Loading layer [==================================================>] 130.9 MB/130.9 MB 3 5f70bf18a086: Loading layer [==================================================>] 1.024 kB/1.024 kB 4 0828a6c7d921: Loading layer [==================================================>] 90.27 MB/90.27 MB 5 8683f0f614c9: Loading layer [==================================================>] 2.048 kB/2.048 kB 6 a89b3190964f: Loading layer [==================================================>] 16.26 MB/16.26 MB 7 ca627f7178ed: Loading layer [==================================================>] 110.1 kB/110.1 kB 8 edec8b16494f: Loading layer [==================================================>] 4.096 kB/4.096 kB 9 Loaded image ID: sha256:b4344393062633aad3f68fdee2ac195cfe9d618d6994ef3f3e03dba088a15fa8 10 [root@docker03 images]#
给镜像打tag
1 [root@docker03 images]# docker images 2 REPOSITORY TAG IMAGE ID CREATED SIZE 3 harbor.suixingpay.com/kube/dnsmasq-metrics-amd64 1.0 5271aabced07 8 months ago 14 MB 4 <none> <none> b43443930626 16 months ago 230 MB 5 [root@docker03 images]# docker tag b43443930626 harbor.suixingpay.com/kube/heapster_grafana:v2.6.0-2 6 [root@docker03 images]# docker images 7 REPOSITORY TAG IMAGE ID CREATED SIZE 8 harbor.suixingpay.com/kube/dnsmasq-metrics-amd64 1.0 5271aabced07 8 months ago 14 MB 9 harbor.suixingpay.com/kube/heapster_grafana v2.6.0-2 b43443930626 16 months ago 230 MB 10 [root@docker03 images]#
上次镜像到harbor
1 [root@docker03 images]# docker push harbor.suixingpay.com/kube/heapster_grafana:v2.6.0-2 2 The push refers to a repository [harbor.suixingpay.com/kube/heapster_grafana] 3 5f70bf18a086: Mounted from kube/dnsmasq-metrics-amd64 4 edec8b16494f: Pushed 5 ca627f7178ed: Pushed 6 a89b3190964f: Pushed 7 8683f0f614c9: Pushed 8 0828a6c7d921: Pushed 9 78dbfa5b7cbc: Pushed 10 v2.6.0-2: digest: sha256:daea3fd319873e0f460b26885698a18c0dfcea404d0e03969aeaefeb35d4c278 size: 3018 11 [root@docker03 images]#
Harbor页面展示
碎片化时间学习和你一起终身学习