部署Harbor

Harbor是一個用於存儲Docker鏡像的企業級Registry服務。html


  • 安裝docker:
# curl http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker.repo# yum makecache fast# yum install -y docker-ce# systemctl start docker && systemctl enable docker

  • 下載最新的docker-compose二進制文件:
# curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose# chmod +x /usr/local/bin/docker-compose

  • 下載harbor離線安裝包:

github地址:https://github.com/goharbor/harbor/releaseslinux

# cd /software# wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.1.tgz# tar zxf harbor-offline-installer-v1.9.1.tgz

  • 安裝harbor:
# cd harbor/# vim harbor.ymlhostname: harbor.lzxlinux.com               #域名harbor_admin_password: Harbor12345              #admin用戶初始密碼data_volume: /data              #數據存儲路徑,自動建立log:
  level: info
  local:
    rotate_count: 50
    rotate_size: 200M
    location: /var/log/harbor               #日誌路徑
    # sh install.sh


  • 登陸報錯:
# echo '192.168.1.59 harbor.lzxlinux.com' >> /etc/hosts# docker login harbor.lzxlinux.comUsername: admin
Password: 
Error response from daemon: Get https://harbor.lzxlinux.com/v2/: dial tcp 192.168.1.59:443: connect: connection refused

  • 解決:
# vim /usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry=harbor.lzxlinux.com# systemctl daemon-reload && systemctl restart docker.service

harbor服務器git

# cd /software/harbor# docker-compose down -v# docker-compose up -d

  • 從新登陸:
# docker login harbor.lzxlinux.comUsername: admin
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-storeLogin Succeeded


  • 推送鏡像:
# docker images |grep centoscentos                              latest              0f3e07c0138f        2 weeks ago         220MB# docker tag centos:latest harbor.lzxlinux.com/public/centos:latest# docker push harbor.lzxlinux.com/public/centos:latestThe push refers to repository [harbor.lzxlinux.com/public/centos]9e607bb861a7: Pushed 
latest: digest: sha256:6ab380c5a5acf71c1b6660d645d2cd79cc8ce91b38e0352cbf9561e050427baf size: 529

刷新harbor頁面,能夠看到剛推送到harbor倉庫的鏡像github

在這裏插入圖片描述

相關文章
相關標籤/搜索