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

相关内容

热门资讯

三分钟网页版!大同麻将亲友圈有... 三分钟网页版!大同麻将亲友圈有挂的(透视)详细教程(2024已更新)(哔哩哔哩)相信很多朋友都在电脑...
七分钟辅助器!海南骨牌有外挂的... 七分钟辅助器!海南骨牌有外挂的(透视)详细教程(2021已更新)(哔哩哔哩)1、许多玩家不知道海南骨...
1分钟有辅!微扑克有假(透视)... 1分钟有辅!微扑克有假(透视)详细教程(2022已更新)(哔哩哔哩);(需添加指定薇13670430...
三分钟安装!微扑克模拟器是(透... 三分钟安装!微扑克模拟器是(透视)详细教程(2025已更新)(哔哩哔哩);微扑克模拟器是是一款益智类...
9分钟新版!哈灵麻将助赢神器(... 相信很多朋友都在电脑上玩过哈灵麻将助赢神器吧,但是很多朋友都在抱怨用电脑玩起来不方便。为此小编给大家...
九分钟ai购买!哈糖大菠萝有外... 九分钟ai购买!哈糖大菠萝有外挂的(透视)详细教程(2021已更新)(哔哩哔哩)关于哈糖大菠萝有外挂...
3分钟安装!牌乐门手机麻将有挂... 3分钟安装!牌乐门手机麻将有挂的(透视)详细教程(2020已更新)(哔哩哔哩);科技安装教程;757...
8分钟规律!家家乐牌吧如何开挂... 相信很多朋友都在电脑上玩过家家乐牌吧如何开挂吧,但是很多朋友都在抱怨用电脑玩起来不方便。为此小编给大...
2分钟开桌!闲逸斗地主亲友圈有... 大家肯定在之前闲逸斗地主亲友圈有挂的或者闲逸斗地主亲友圈有挂的中玩过2分钟开桌!闲逸斗地主亲友圈有挂...
分享实测!贵阳天天麻将app软... 分享实测!贵阳天天麻将app软件有假的(透视)详细教程(2020已更新)(哔哩哔哩);一、贵阳天天麻...