本文章僅作為個人筆記
harbor 使用 參考
-
安裝
-
wget https://github.com/docker/compose/releases/download/1.26.2/docker-compose-Linux-x86_64 mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
-
# 生成密鑰(非必須茵汰,若不需要支持https可不生成) cd /home mkdir harbor-keys cd harbor-keys openssl genrsa -out rsa_private.key 2048 # 這一步需要填一些東西,記得別填密碼栏豺,另外 Common Name 填域名或者host里對應當前ip的值(如:master) openssl req -new -key rsa_private.key -out rsa_private.csr openssl x509 -req -days 365 -in rsa_private.csr -signkey rsa_private.key -out rsa_private.crt cd .. # 此處為正式安裝豆胸,若無需https支持可注釋對應配置 wget https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz tar xvf harbor-offline-installer-v2.0.2.tgz cp ./harbor/harbor.yml.tmpl ./harbor/harbor.yml vim ./harbor/harbor.yml hostname: <host_ip> https: port: 443 certificate: /home/harbor-keys/rsa_private.crt private_key: /home/harbor-keys/rsa_private.key yum install -y yum-utils yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo dnf install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm yum install docker-ce -y service docker restart ./harbor/install.sh # 安裝完 訪問 http://<host_ip> 即可查看harbor # 默認用戶名密碼在配置文件內(nèi)晚胡,為 admin Harbor12345 可自行修改 # docker更改配置 vim /etc/docekr/daemon.json { "registry-mirrors": [ "https://<host_ip>:<host_port>" ], "insecure-registries": [ "https://<host_ip>:<host_port>" ] } systemctl daemon-reload service docker restart # 在gui界面新建項目 (例: demo_pro) # 制作鏡像 (例:docker tag mongo 192.168.9.128/demo_pro/demo_mongo:0.0.1)(需先 docker pull mongo) docker tag <image_name> <host_ip>/<private_image_package>/<private_image_name>:<private_image_version>
-
-
上傳制作的鏡像至harbor (例:docker push 192.168.9.128/demo_pro/demo_mongo:0.0.1)
docker login <host_ip> docker push <host_ip>/<private_image_package>/<private_image_name>:<private_image_version>
再訪問 http://<host_ip> 即可看到新上傳的鏡像了
-
服務操作:(于/harbor 目錄運行)
docker-compose stop docker-compose start