存储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

相关内容

热门资讯

aapoker透视软件!wep... aapoker透视软件!wepoker辅助分析器(透视)竟然是真的有挂(微扑克教程)1)wepoke...
透视辅助!心悦提坑神器软件下载... 透视辅助!心悦提坑神器软件下载(辅助挂)确实是有挂(详细辅助技巧教程)1、心悦提坑神器软件下载透视辅...
透视插件!wepoker德州辅... 透视插件!wepoker德州辅助挂下载,德州透视(详细辅助详细教程)相信很多朋友都在电脑上玩过wep...
hhpoker辅助下载!hhp... hhpoker辅助下载!hhpoker开挂教程(透视)竟然真的是有挂(普及教程)1、金币登录送、破产...
透视辅助!功夫川麻bug(辅助... 透视辅助!功夫川麻bug(辅助挂)本来真的有挂(详细辅助曝光教程)1、全新机制【功夫川麻bug软件透...
透视中牌率!wepoker软件... 透视中牌率!wepoker软件辅助挂,wepoker作弊辅助挂(详细辅助AA德州教程)是一款可以让一...
德普之星辅助功能如何打开!we... 德普之星辅助功能如何打开!wepoker辅助分析器(透视)一贯是有挂(教你攻略);1、进入游戏-大厅...
透视辅助!丰城双剑新版最强高分... 透视辅助!丰城双剑新版最强高分攻略(辅助挂)都是有挂(详细辅助透明教程)1、下载好丰城双剑新版最强高...
透视智能ai!uupoker透... 透视智能ai!uupoker透视挂,wepoker透视辅助教程(详细辅助普及教程);wepoker透...
智星德州有脚本吗!hhpoke... 智星德州有脚本吗!hhpoker德州机器人(透视)好像真的是有挂(攻略方法)1、这是跨平台的智星德州...