存储Docker镜像至Harbor

5 篇文章 0 订阅
1 篇文章 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

  • 29
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值