十四、部署harbor

1、下载docker-compose

[root@k8s-node01 ~]# curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[root@k8s-node01 harbor]# chmod +x /usr/local/bin/docker-compose 
[root@k8s-node01 ~]# docker-compose --version
docker-compose version 1.24.1, build 4667896b

2、下载harbor离线安装包

地址:https://github.com/goharbor/harbor/releases

[root@k8s-node01 harbor]# wget https://github.com/goharbor/harbor/releases/download/v1.9.2/harbor-offline-installer-v1.9.2.tgz
[root@k8s-node01 harbor]# tar xf harbor-offline-installer-v1.9.2.tgz 
[root@k8s-node01 harbor]# cd harbor
[root@k8s-node01 harbor]# ls
harbor.v1.9.2.tar.gz  harbor.yml  install.sh  LICENSE  prepare
[root@k8s-node01 harbor]# vim harbor.yml 
hostname: 10.16.8.152
harbor_admin_password: 123456

[root@k8s-node01 harbor]# ./prepare 
[root@k8s-node01 harbor]# ./install.sh 
[root@k8s-node01 harbor]# docker-compose ps
      Name                     Command                  State                 Ports          
---------------------------------------------------------------------------------------------
harbor-core         /harbor/harbor_core              Up (healthy)                            
harbor-db           /docker-entrypoint.sh            Up (healthy)   5432/tcp                 
harbor-jobservice   /harbor/harbor_jobservice  ...   Up (healthy)                            
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up (healthy)   127.0.0.1:1514->10514/tcp
harbor-portal       nginx -g daemon off;             Up (healthy)   8080/tcp                 
nginx               nginx -g daemon off;             Up (healthy)   0.0.0.0:80->8080/tcp     
redis               redis-server /etc/redis.conf     Up (healthy)   6379/tcp                 
registry            /entrypoint.sh /etc/regist ...   Up (healthy)   5000/tcp                 
registryctl         /harbor/start.sh                 Up (healthy)                

3、访问

http://10.16.8.152/harbor/projects

4、上传镜像

[root@k8s-node01 harbor]# vim /etc/docker/daemon.json
 "insecure-registries":["10.16.8.152"]
[root@k8s-node01 harbor]# systemctl restart docker
#启动harbor [root@k8s
-node01 harbor]# docker-compose up -d [root@k8s-node01 harbor]# docker images |grep tomcat tomcat v1 29302f19b196 11 months ago 480MB #打tag [root@k8s-node01 harbor]# docker tag tomcat:v1 10.16.8.152/xw_dev/tomcat:v1 [root@k8s-node01 harbor]# docker images |grep tomcat 10.16.8.152/xw_dev/tomcat v1 29302f19b196 11 months ago 480MB tomcat v1 29302f19b196 11 months ago 480MB

在harbor页面上新建一个用户xw,给项目xw_dev新增这个用户

#docker登录harbor
[root@k8s-node01 harbor]# docker login 10.16.8.152
Username: xw
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
#上传镜像
[root@k8s-node01 harbor]# docker push 10.16.8.152/xw_dev/tomcat:v1
The push refers to repository [10.16.8.152/xw_dev/tomcat]
803a116ba9fc: Pushed 
67279349aea5: Pushed 
b01d64c12b05: Pushed 
f972d139738d: Pushed 
v1: digest: sha256:1ba92d762ce00c4a6697f3ddd480e2567df530b310d0957e8dec6b97ea795386 size: 1164

原文地址:https://www.cnblogs.com/xw115428/p/11956463.html