一、安裝Docker-compose
下載地址:
https://github.com/docker/compose/releases
文件下載下來是個(gè)二進(jìn)制文件,加x權(quán)限放到/usr/bin目錄下
[root@node4 harbor]# ls
docker-compose-linux-x86_64 harbor harbor-offline-installer-v2.3.1.tgz
[root@node4 harbor]# cp docker-compose-Linux-x86_64 /usr/bin/docker-compose
[root@node4 harbor]# chmod +x /usr/bin/docker-compose
二、安裝harbor
下載地址:
https://github.com/goharbor/harbor/releases
解壓安裝包,修改harbor.yml.tmpl文件并重命名成harbor.yml,這是harbor的配置文件,執(zhí)行安裝之前要改好,我這里只改了主機(jī)名和禁用了https
[root@node4 harbor]# ls
common docker-compose.yml harbor.yml install.sh prepare
common.sh harbor.v2.3.1.tar.gz harbor.yml.tmpl.bak LICENSE
[root@node4 harbor]# cat harbor.yml |grep hostname
# The IP address or hostname to access admin UI and registry service.
hostname: node4
在執(zhí)行./install安裝之前,確保docker處于運(yùn)行狀態(tài)。install完成后,默認(rèn)使用80端口即訪問。
三、harbor啟動(dòng)與停止
啟動(dòng),啟動(dòng)時(shí)要進(jìn)入harbor的安裝目錄
docker-compose up -d
停止
docker-compose stop
四、docker登錄harbor
http方式,需要修改/etc/dcoker/daemon.json
{
"insecure-registries": ["node4"]
}
登錄
[root@node4 ~]# docker login 192.168.21.34
Authenticating with existing credentials...
Stored credentials invalid or expired
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
五、上傳鏡像到倉庫
先pull一個(gè)Nginx:1.15到本地,打tag,上傳
[root@node4 ~]# docker pull nginx:1.15
1.15: Pulling from library/nginx
743f2d6c1f65: Pull complete
6bfc4ec4420a: Pull complete
688a776db95f: Pull complete
Digest: sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
Status: Downloaded newer image for nginx:1.15
docker.io/library/nginx:1.15
[root@node4 ~]# docker tag nginx:1.15 192.168.21.34/release/nginx:v1.15
[root@node4 ~]# docker push 192.168.21.34/release/nginx:v1.15
The push refers to repository [192.168.21.34/release/nginx]
332fa54c5886: Pushed
6ba094226eea: Pushed
6270adb5794c: Pushed
v1.15: digest: sha256:e770165fef9e36b990882a4083d8ccf5e29e469a8609bb6b2e3b47d9510e2c8d size: 94
8