登录后台

页面导航

本文编写于 179 天前,最后修改于 179 天前,其中某些信息可能已经过时。

Harbor(港口)私有仓库部署

Harbor需要安装docker-compose组件

去Harbor官网下载压缩包并解压,然后启动安装脚本安装

yum install docker-compose -y
wget https://github.com/goharbor/harbor/releases/download/v1.10.4/harbor-offline-installer-v1.10.4.tgz #建议翻墙后下载,再传到宿主机上,这样速度快
tar xf harbor-offline-installer-v1.10.4.tgz -C /opt/ #解压
cd /opt/
ln -s /opt/harbor-1.10/ /opt/harbor/ #加个软链接,方便以后升级
cd harbor
vim harbor.yml #编辑yml文件修改以下参数
hostname: harbor.chenqi.com #主机名可以加上自己的域名,加上ip也可以
# 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
# 把https部分全部注释掉
docker rm -f $(docker ps -a -q) #安装之前先把所有容器全都清空
./install.sh 执行安装脚本 #执行安装脚本
由于yml文件的hostname改成了域名,所以在宿主机和自己的电脑上都要修改host文件,添加对应的域名解析即可。
浏览器访问域名即可访问harbor的web界面

从Harbor推镜像和拉镜像

首先要在daemon.json上配置安全仓库

vim /etc/docker/daemon.json

{
  "registry-mirrors": ["https://kwutlccp.mirror.aliyuncs.com"],
"graph":"/data/docker",
"insecure-registries":["172.168.2.245:5000","harbor.chenqi.com"]
}
systemctl restart docker #重启docker生效
docker login harbor.chenqi.com 
#推镜像前需要登录harbor,初始账号密码为admin/Harbor12345
docker tag hello-world harbor.chenqi.com/library/hello-world
#推镜像前需要先打上tag,以一个hello-world镜像为例
docker push harbor.chenqi.com/library/hello-world
#推hello-world镜像
docker rmi -f hello-world #删除hello-world镜像
docker pull harbor.chenqi.com/library/hello-world
#从harbor上拉hello-world镜像
[root@harbor ~]# docker images
REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE
goharbor/chartmuseum-photon             v1.10.4             4d6611b3b6a9        2 weeks ago         178MB
goharbor/harbor-migrator                v1.10.4             c6ba18cc92c0        2 weeks ago         357MB
goharbor/redis-photon                   v1.10.4             1733199a8380        2 weeks ago         122MB
goharbor/clair-adapter-photon           v1.10.4             4d7fec33eb52        2 weeks ago         61.2MB
goharbor/clair-photon                   v1.10.4             48f8d69c3f63        2 weeks ago         171MB
goharbor/notary-server-photon           v1.10.4             3cc30fe05041        2 weeks ago         143MB
goharbor/notary-signer-photon           v1.10.4             46ecb328c811        2 weeks ago         140MB
goharbor/harbor-registryctl             v1.10.4             503dda3f193e        2 weeks ago         102MB
goharbor/registry-photon                v1.10.4             96183605aaeb        2 weeks ago         84.5MB
goharbor/nginx-photon                   v1.10.4             f8f638056eee        2 weeks ago         43.6MB
goharbor/harbor-log                     v1.10.4             b0de11e1ba03        2 weeks ago         82.1MB
goharbor/harbor-jobservice              v1.10.4             91c262f629d2        2 weeks ago         143MB
goharbor/harbor-core                    v1.10.4             cc013d5caa80        2 weeks ago         129MB
goharbor/harbor-portal                  v1.10.4             fec0c21d0a67        2 weeks ago         51.7MB
goharbor/harbor-db                      v1.10.4             2f077a558a2c        2 weeks ago         161MB
goharbor/prepare                        v1.10.4             85d07a7c81cd        2 weeks ago         168MB
harbor.chenqi.com/library/hello-world   latest              bf756fb1ae65        6 months ago        13.3kB
#此时发现,hello-world镜像已存在harbor.chenqi.com/library/hello-world