主机规划
主机名 | IP地址 | 角色 | 操作系统 | 硬件配置 |
---|---|---|---|---|
harbor | 10.62.158.204 | 私有镜像仓库 | CentOS 7 | 1 Core/2G Memory/20G磁盘 |
设置主机名
[root@localhost ~]# hostnamectl set-hostname barbor
[root@localhost ~]# exit
登出
Connection closed by foreign host.
Disconnected from remote host(测试机 - 204) at 16:38:48.
安装Docker - 在线安装
安装 yum-utils
软件提供 yum-config-manager
命令
[root@harbor ~]# yum install yum-utils -y
添加阿里云 docker-ce
仓库
[root@harbor ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装 docker
软件包
[root@harbor ~]# yum install docker-ce-20.10.9-3.el7 -y
启动 docker
并设置服务随机自启
[root@harbor ~]# systemctl enable docker --now
安装docker-compose
上传 Docker Compose
二进制程序文件 - docker-compose
链接:https://pan.baidu.com/s/1xhK4Y2WQczWk-ZGPUbcdTA
提取码:zfyp
[root@barbor ~]# ls
anaconda-ks.cfg docker-compose sysconfigure.sh
添加执行权限
[root@barbor ~]# chmod +x docker-compose
移动 docker-compose
程序文件到 /usr/bin 目录下
[root@harbor ~]# mv docker-compose /usr/bin
查看 docker-compose
是否生效
[root@barbor ~]# docker-compose --version
docker-compose version 1.25.0, build 0a186604
安装 Harbor 私有镜像仓库
上传 harbor
离线镜像包并解压 - harbor-v2.5.1.tgz
链接:https://pan.baidu.com/s/15XYPfDpbX8jAlpsZBMoysQ
提取码:cm0j
[root@barbor ~]# ls
anaconda-ks.cfg docker-compose harbor-v2.5.1.tgz sysconfigure.sh
[root@harbor ~]# tar -xf harbor-v2.5.1.tgz
进入解压目录
[root@harbor ~]# cd harbor
导入 Harbor
镜像文件
[root@barbor harbor]# docker load -i harbor.v2.5.1.tar.gz
拷贝模版配置文件
[root@barbor harbor]# cp harbor.yml.tmpl harbor.yml
[root@barbor harbor]# ls
common.sh harbor.v2.5.1.tar.gz harbor.yml harbor.yml.tmpl install.sh LICENSE prepare
修改配置文件中的如下内容 - HTTP协议
[root@harbor harbor]# vim harbor.yml
#上述内容省略...
hostname: 10.62.158.204 #Harbor主机IP地址
#https: 注释https访问方式(需要有效证书才可以使用)
# https port for harbor, default is 443
#port: 443 注释https端口
# The path of cert and key files for nginx
#certificate: /your/certificate/path 注释证书文件
#private_key: /your/private/key/path 注释证书密钥文件
harbor_admin_password: 12345 #admin密码
执行 install.sh
安装脚本
[root@harbor harbor]# ./install.sh
# 出现以下提示表示安装完成
...
✔ ----Harbor has been installed and started successfully.----
# 查看已启动的harbor服务,共9个服务
[root@barbor harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4fc1efb3d7f4 goharbor/nginx-photon:v2.5.1 "nginx -g 'daemon of…" About a minute ago Up About a minute (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp nginx
bdd6ade33c43 goharbor/harbor-jobservice:v2.5.1 "/harbor/entrypoint.…" About a minute ago Up About a minute (healthy) harbor-jobservice
a2897a477c79 goharbor/harbor-core:v2.5.1 "/harbor/entrypoint.…" About a minute ago Up About a minute (healthy) harbor-core
0e7b14860cb5 goharbor/harbor-registryctl:v2.5.1 "/home/harbor/start.…" About a minute ago Up About a minute (healthy) registryctl
4f8261e551de goharbor/harbor-db:v2.5.1 "/docker-entrypoint.…" About a minute ago Up About a minute (healthy) harbor-db
5f03d08f19ed goharbor/registry-photon:v2.5.1 "/home/harbor/entryp…" About a minute ago Up About a minute (healthy) registry
d2d503b01a5d goharbor/harbor-portal:v2.5.1 "nginx -g 'daemon of…" About a minute ago Up About a minute (healthy) harbor-portal
3337c3e9a280 goharbor/redis-photon:v2.5.1 "redis-server /etc/r…" About a minute ago Up About a minute (healthy) redis
ae6e384c4e85 goharbor/harbor-log:v2.5.1 "/bin/sh -c /usr/loc…" About a minute ago Up About a minute (healthy) 127.0.0.1:1514->10514/tcp harbor-log
本机指定 Harbor
仓库地址,指定后可在本机进行镜像文件的上传与下载,其他主机需要使用 Harbor
私有仓库时,也需修改以下内容
[root@harbor harbor]# vim /etc/docker/daemon.json
{
"insecure-registries": ["http://10.62.158.204"]
}
修改 daemon.json
文件后,需重启 docker
使配置生效
[root@harbor harbor]# systemctl restart docker
重启 Harbor
仓库(docker
重启后,Harbor
相关组件并不会自动重启,需要手动重启)
# 关闭Harbor全部相关程序
[root@harbor harbor]# docker-compose down
# 启动Harbor全部相关程序
[root@harbor harbor]# docker-compose up -d
浏览器访问 Harbor
页面,账号为 admin
,密码为 harbor.yml
文件中定义的密码:123456
http://10.62.158.204/