跳到主要内容

私有Docker镜像仓库Harbor搭建

下载Harbor安装包:

export HARBOR_VERSION=2.5.6
wget https://github.com/goharbor/harbor/releases/download/v${HARBOR_VERSION}/harbor-offline-installer-v${HARBOR_VERSION}.tgz
tar xvf harbor-offline-installer-v${HARBOR_VERSION}.tgz
cd harbor

修改配置文件:

cp harbor.yml.tmpl harbor.yml
hostname: 192.168.41.52

# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 10086

安装运行:

bash install.sh

效果:

image-20240905094944712

修改/etc/docker/daemon.json文件

"insecure-registries": [
"192.168.41.52:10086"
]

重启:

systemctl daemon-reload
systemctl restart docker

在另外一台服务器上:

配置私有仓库:

   {
"insecure-registries": ["192.168.41.52:10086"]
}

登录私有仓库:

docker login 192.168.41.52:10086

为镜像打标签:

docker tag casll/gateway:latest 192.168.41.52:10086/library/casll/gateway:latest

推送到私有仓库:

docker push 192.168.41.52:10086/library/casll/gateway:latest

拉取镜像:

   docker pull 192.168.41.52:10086/library/casll/gateway:latest

效果:

image-20240905101118728