存储Docker镜像至Harbor
创始人
2024-09-25 05:50:31
0

提前安装好docker和docker compose

[root@docker compose]# docker version

[root@docker compose]# docker  compose version

下载harbor的压缩包

https://github.com/goharbor/harbor/releases/download/v2.10.3/harbor-offline-installer-v2.10.3.tgz

[root@docker compose]# mkdir /harbor
[root@docker compose]# cd /harbor

[root@docker harbor]# ls
harbor-offline-installer-v2.10.3.tgz

解压

[root@docker harbor]# tar xf harbor-offline-installer-v2.10.3.tgz 
[root@docker harbor]# ls
harbor  harbor-offline-installer-v2.10.3.tgz

[root@docker harbor]# cd harbor
[root@docker harbor]# ls
common.sh  harbor.v2.10.3.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@docker harbor]#

修改配置文件

[root@docker harbor]# cp harbor.yml.tmpl harbor.yml

[root@harbor harbor]# vim harbor.yml


hostname: 192.168.252.136   #修改

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80   #修改

#注释掉了https的配置
#其他的配置没有修改
# https related config
#https:
  # https port for harbor, default is 443
#  port: 443
  # The path of cert and key files for nginx
#  certificate: /your/certificate/path
#  private_key: /your/private/key/path

执行安装脚本

[root@docker harbor]# ./install.sh 

[Step 0]: checking if docker is installed ...

Note: docker version: 26.1.4

[Step 1]: checking docker-compose is installed ...

Note: Docker Compose version v2.27.1

[Step 2]: loading Harbor images ...


Loaded image: goharbor/registry-photon:v2.10.3
Loaded image: goharbor/notary-server-photon:v2.10.3
Loaded image: goharbor/notary-signer-photon:v2.10.3
Loaded image: goharbor/harbor-log:v2.10.3
Loaded image: goharbor/redis-photon:v2.10.3
Loaded image: goharbor/harbor-jobservice:v2.10.3
Loaded image: goharbor/prepare:v2.10.3
Loaded image: goharbor/harbor-core:v2.10.3
Loaded image: goharbor/harbor-registryctl:v2.10.3
Loaded image: goharbor/nginx-photon:v2.10.3
Loaded image: goharbor/trivy-adapter-photon:v2.10.3
Loaded image: goharbor/harbor-portal:v2.10.3
Loaded image: goharbor/harbor-db:v2.10.3
Loaded image: goharbor/harbor-exporter:v2.10.3


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /harbor/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir


Note: stopping existing Harbor instance ...


[Step 5]: starting Harbor ...
[+] Running 10/10
 ✔ Network harbor_harbor        Created                                                                                 0.1s 
 ✔ Container harbor-log         Started                                                                                 0.0s 
 ✔ Container redis              Started                                                                                 0.1s 
 ✔ Container harbor-db          Started                                                                                 0.1s 
 ✔ Container registryctl        Started                                                                                 0.1s 
 ✔ Container registry           Started                                                                                 0.1s 
 ✔ Container harbor-portal      Started                                                                                 0.1s 
 ✔ Container harbor-core        Started                                                                                 0.1s 
 ✔ Container harbor-jobservice  Started                                                                                 0.1s 
 ✔ Container nginx              Started                                                                                 0.1s 
✔ ----Harbor has been installed and started successfully.----
[root@docker harbor]# 

查看harbor相关容器运行情况

[root@docker harbor]# docker compose ps

在windows机器上访问网站,并配置harbor

http://192.168.254.136/

默认的登录的用户名和密码
admin
Harbor12345

在harbor里创建一个项目 newProject
并且新建一个用户 user1  密码是Admin@123
授权 newProject 这个项目允许 user1 这个用户去访问,授予项目管理员权限

在所有其他机器上配置这个仓库

[root@docker1 ~]# cat /etc/docker/daemon.json
{
  "registry-mirrors": ["https://ruk1gp3w.mirror.aliyuncs.com"],
  "insecure-registries" : ["192.168.254.136:80"]
}

重启docker守护进程配置文件以及docker

[root@docker1 ~]# systemctl daemon-reload
[root@docker1 ~]# systemctl restart docker

在原来安装harbor的宿主机上,重新启动harbor相关的容器

[root@docker harbor]# cd /harbor/harbor
[root@docker harbor]# docker compose up -d

[root@docker harbor]# docker compose restart

登录使用

user1用户,密码是Admin@123

[root@docker docker]# docker login  192.168.254.136:80
Username: user1
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@docker docker]# docker tag myapp:1.0 192.168.254.136:80/newProject/myapp:1.0
[root@docker docker]# docker push 192.168.254.136:80/newProject/myapp:1.0

其他机器上传镜像

root@docker:~/liu# docker tag 2ba278e9c4a1 192.168.254.136:80/newProject/myapp:1.1

root@docker:~/liu# docker push 192.168.254.136:80/newProject/myapp:1.1

其他机器拉取镜像

需要先登录harbor仓库

[root@nfs ~]# docker login  192.168.254.136:80
Username: user1
Password: 

[root@nfs ~]# docker pull  192.168.254.136:80/newProject/myapp:1.0

[root@nfs ~]# docker pull  192.168.254.136:80/newProject/myapp:1.1

相关内容

热门资讯

透视系统!wepoker正确养... 透视系统!wepoker正确养号方法,德普之星透视辅助(起初有开挂辅助插件);无需打开直接搜索加(薇...
第4分钟步骤!新超凡大厅怎么开... 第4分钟步骤!新超凡大厅怎么开挂(透视)微信小程序微乐辅助器(有挂细节)1、下载安装好微信小程序微乐...
第8分钟了解!wepoker有... 您好:广东雀神祈福真的有用吗这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用...
六秒钟知晓“微乐三带辅助”原先... 您好:微乐三带辅助这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的牌特别...
透明工具!pokemmo免费脚... 透明工具!pokemmo免费脚本,wepoker辅助软件视频(原先有开挂辅助软件);无需打开直接搜索...
8分钟方针!微信小程序雀神挂件... 8分钟方针!微信小程序雀神挂件下载(透视)新道游科技透视免费版(有挂详细);无需打开直接搜索薇:13...
一分钟了解!哈糖大菠萝万能挂,... 一分钟了解!哈糖大菠萝万能挂,wejoker透视方法,曝光教程(新版有挂)1、下载安装好哈糖大菠萝万...
第三秒钟指导“青鸟辅助平台”起... 第三秒钟指导“青鸟辅助平台”起初有开挂辅助器(有挂解密)1、下载安装好青鸟辅助平台,进入游戏主界面,...
透明教程!aapoker透视插... 您好:aapoker透视插件这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用...
第4分钟手筋!越乡游义乌辅助器... 第4分钟手筋!越乡游义乌辅助器安全吗(透视)微信小程序开心十三张脚本(有挂分析)1、下载安装好微信小...