配置客户端

  • 配置自定义域名的方式访问,修改 /etc/hosts 文件,在底部追加
  1. 192.168.0.133 harbor.hzlim.cn
  • 修改 /etc/docker/daemon.json 文件,其中 insecure-registries 配置为我们的私服地址
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "registry-mirrors": [
    "https://k7da99jp.mirror.aliyuncs.com/",
    "https://dockerhub.azk8s.cn",
    "https://registry.docker-cn.com"
  ],
  "insecure-registries": [
    "https://harbor.hzlim.cn:8443"
  ],
  "storage-driver": "overlay2"
}

重启docker

systemctl restart docker
docker info

Harbor上传镜像

# 在项目中标记镜像
docker tag hello-world harbor.hzlim.cn:8443/hello-world/hello-world:last
# 登录 Harbor
docker login harbor.hzlim.cn:8443 -u admin -p Harbor12345
# 推送镜像到项目
docker push harbor.hzlim.cn:8443/hello-world/hello-world:last

下载镜像

#登录
docker login harbor.hzlim.com:8443 -u admin -p Harbor12345
#拉取
docker pull harbor.hzlim.cn:8443/hello-world/hello-world:last