1 docker 安裝
《centos 7.6.1810安裝與使用docker 18.09.6》:https://blog.csdn.net/CleverCode/article/details/107181446
2 安裝docker-compose
# curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
3 安裝harbor
1 下載harbor-online-installer-v1.10.3.tgz
https://github.com/goharbor/harbor/releases
2 解壓
# tar xf harbor-online-installer-v1.10.3.tgz
3 修改配置
# cd harbor
vi harbor.yml
hostname: 172.16.159.162
http:
port: 8081
harbor_admin_password: clevercode12345
hostname:變成自己主機的ip
port:自己定義,我改成了8081
harbor_admin_password:是管理員登錄密碼,我改成了clevercode12345
4 安裝
# ./prepare //預處理
# ./install.sh //執行安裝操作
5 查看
6 登錄
http://172.16.159.162:8081/ 賬號:admin 密碼:clevercode12345
7 重啓
再次執行./install.sh即可
./install.sh
4 向harbor中推送鏡像與下載鏡像
4.1 上傳鏡像
1 在harbor中新建項目
在172.16.159.162:8081 新建test項目
2 拉取一個測試鏡像
# docker pull busybox
3 查看鏡像
4 給鏡像打標籤
# docker tag busybox:latest 172.16.159.162:8081/myproject/busybox:v1
# docker tag
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
docker tag 鏡像名:${version} 鏡像倉庫/鏡像名:${version}
5 登錄harbor
[root@localhost harbor]# docker login 172.16.159.162:8081
Username: admin
Password:
Error response from daemon: Get https://172.16.159.162:8081/v2/: http: server gave HTTP response to HTTPS client
[root@localhost harbor]#
報https問題,將172.16.159.162:8081加入到私服
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn","http://hub-mirror.c.163.com","https://dockerhub.mirrors.nwafu.edu.cn"],
"insecure-registries": ["172.16.159.162:8081"],
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"data-root": "/var/lib/docker"
}
重啓docker
# systemctl restart docker
再次登錄正常
[root@localhost harbor]# docker login 172.16.159.162:8081
Username: 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-store
Login Succeeded
5 推送鏡像
[root@localhost harbor]# docker push 172.16.159.162:8081/myproject/busybox:v1
The push refers to repository [172.16.159.162:8081/myproject/busybox]
50761fe126b6: Pushed
v1: digest: sha256:2131f09e4044327fd101ca1fd4043e6f3ad921ae7ee901e9142e6e36b354a907 size: 527
[root@localhost harbor]#
6 查看鏡像
http://172.16.159.162:8081/
4.2 下載鏡像
# docker pull 172.16.159.162:8081/myproject/busybox:v1
5 兩臺harbor主機,實現鏡像同步
1、按照1,2,3章節啓動harbor
harbor1: 172.16.159.162
harbor2: 172.16.159.164
2 在 172.16.159.162:8081上面
【倉庫管理】 => 【新建目標】
目標URL:http://172.16.159.164:8081/
訪問ID: admin
訪問密碼: clevercode12345
3 在 172.16.159.164:8081上面
【倉庫管理】 => 【新建目標】
目標URL:http://172.16.159.162:8081/
訪問ID: admin
訪問密碼: clevercode12345