部署harbor

安装私有仓库,需要先安装docker,docker-compose
docker地址:https://download.docker.com/linux/static/stable/x86_64/
docker-compose地址:https://github.com/docker/compose/releases
harbor地址:https://github.com/goharbor/harbor/releases

1. 部署docker,自行部署

2. 部署docker-compose
把下载的包docker-compose-linux-x86_64上传到/usr/bin目录下
重命名:mv docker-compose-linux-x86_64 docker-compose

[root@k8s-master1 ~]# mv docker-compose-linux-x86_64 /usr/bin/docker-compose

 

授权:chmod 755 docker-compose

[root@k8s-master1 ~]# chmod 755  /usr/bin/docker-compose 

 

查询版本:docker-compose version

[root@k8s-master1 ~]# docker-compose version
Docker Compose version v2.3.4

 

3. 部署harbor

把下载的包harbor-offline-installer-v2.3.4.tgz上传/root目录
解压:tar -xzvf harbor-offline-installer-v2.3.4.tgz -C /usr/local

[root@k8s-master1 ~]# tar -xzvf harbor-offline-installer-v2.3.4.tgz -C /usr/local
harbor/harbor.v2.3.4.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl

 

切换到解压后目录:cd /usr/local/harbor

[root@k8s-master1 ~]# cd /usr/local/harbor

 

复制一份配置模版:cp harbor.yml.tmpl  harbor.yml

[root@k8s-master1 harbor]# cp harbor.yml.tmpl harbor.yml
[root@k8s-master1 harbor]# ll
total 596292
-rw-r--r-- 1 root root      3361 Nov  9  2021 common.sh
-rw-r--r-- 1 root root 610560420 Nov  9  2021 harbor.v2.3.4.tar.gz
-rw-r--r-- 1 root root      7840 Nov  9  2021 harbor.yml.tmpl
-rwxr-xr-x 1 root root      2500 Nov  9  2021 install.sh
-rw-r--r-- 1 root root     11347 Nov  9  2021 LICENSE
-rwxr-xr-x 1 root root      1881 Nov  9  2021 prepare
-rw-r--r-- 1 root root      7840 Oct 27 15:42  harbor.ym

 

修改 harbor.yml配置:hostname修改为本机地址,注释掉https,其他默认

检查环境:./prepare

执行安装:./install.sh

安装完成后检查服务是否起来:

[root@k8s-master1 harbor]# docker-compose ps
NAME                COMMAND                  SERVICE             STATUS              PORTS
harbor-core         "/harbor/entrypoint.…"   core                running (healthy)   
harbor-db           "/docker-entrypoint.…"   postgresql          running (healthy)   
harbor-jobservice   "/harbor/entrypoint.…"   jobservice          running (healthy)   
harbor-log          "/bin/sh -c /usr/loc…"   log                 running (healthy)   127.0.0.1:1514->10514/tcp
harbor-portal       "nginx -g 'daemon of…"   portal              running (healthy)   
nginx               "nginx -g 'daemon of…"   proxy               running (healthy)   0.0.0.0:80->8080/tcp
redis               "redis-server /etc/r…"   redis               running (healthy)   
registry            "/home/harbor/entryp…"   registry            running (healthy)   
registryctl         "/home/harbor/start.…"   registryctl         running (healthy)   

使用浏览器登录:http://ip   默认账号密码:admin/Harbor12345   密码在harbor.yml文件中可修改

 

配置dammon.json文件并重启docker,如果没有需要手动添加,否则无法推送镜像

[root@k8s-master1 harbor]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://registry.docker-cn.com"],
  "insecure-registries":["192.168.198.144:80"]
}

[root@k8s-master1 harbor]# systemctl restart docker

 

给镜像打tag,即可正常push或者pull

[root@k8s-master1 harbor]# docker tag xm_nginx:latest 192.168.198.144:80/xmzw/xm_nginx:latest

登录harbor,push镜像

[root@k8s-master1 harbor]# docker login 192.168.198.144:80
Username: admin
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-master1 harbor]# 
[root@k8s-master1 harbor]# 
[root@k8s-master1 harbor]# docker push 192.168.198.144:80/xmzw/xm_nginx:latest
The push refers to repository [192.168.198.144:80/xmzw/xm_nginx]
493f189383c5: Pushed 
1a2e845ebb60: Pushed 
9281fddfa180: Pushed 
50ec3c2f70c4: Pushed 
34542b8723eb: Pushed 
1055e8af2635: Pushed 
fe7b1e9bf792: Pushed 
latest: digest: sha256:6c8c203cac5db42452a038907af537c126aad6cc15fa660f680fedbb223291fe size: 1778

 

posted @ 2022-10-27 16:11  IT运维成长笔记  阅读(342)  评论(0编辑  收藏  举报