Docker私有倉庫Harbor使用操作


Harbor頁面基礎操作

1):網頁登陸http://192.168.100.61/

默認賬戶密碼:admin  Harbor12345
[root@localhost ~]# cat /data/harbor/harbor.cfg | grep harbor_admin_password

2):用戶管理

系統管理--用戶管理--創建用戶

3):新建一個項目

4):上傳下載鏡像到Harbor倉庫

[root@localhost ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1	docker2
[root@localhost ~]# cat /etc/docker/daemon.json
{
  "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.100.61:5000"],
  "insecure-registries": ["docker2:80"]
}
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker

# 把要上傳的鏡像打上合適的標簽
[root@localhost ~]# docker tag busybox:latest docker2:80/demo/busybox:v0.1
[root@localhost ~]# docker tag nginx:1.14-alpine docker2:80/demo/nginx:v0.1
[root@localhost ~]# docker tag nginx:1.14 docker2:80/demo/nginx:v0.2
[root@localhost ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
docker2:80/demo/busybox         v0.1                83aa35aa1c79        5 days ago          1.22MB
docker2:80/demo/nginx           v0.1                8a2fb25a19f5        11 months ago       16MB
docker2:80/demo/nginx           v0.2                295c7be07902        11 months ago       109MB

# 登錄harbor倉庫
[root@localhost ~]# docker login docker2:80
Username: admin
Password:
Login Succeeded

# 上傳鏡像
[root@localhost ~]# docker push docker2:80/demo/busybox:v0.1
The push refers to repository [docker2:80/demo/busybox]
a6d503001157: Pushed
v0.1: digest: sha256:afe605d272837ce1732f390966166c2afff5391208ddd57de10942748694049d size: 527
# 如果不知道tag,會把這個鏡像的所有tag都上傳
[root@localhost ~]# docker push docker2:80/demo/nginx
The push refers to repository [docker2:80/demo/nginx]
076c58d2644f: Pushed
b2cbae4b8c15: Pushed
5ac9a5170bf2: Pushed
a464c54f93a9: Pushed
v0.1: digest: sha256:a3a0c4126587884f8d3090efca87f5af075d7e7ac8308cffc09a5a082d5f4760 size: 1153
82ae01d5004e: Pushed
b8f18c3b860b: Pushed
5dacd731af1b: Pushed
v0.2: digest: sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078 size: 948

5):再harbor上驗證上傳成功

6):拉取harbor中的鏡像

# 刪除鏡像
[root@localhost ~]# docker rmi docker2:80/demo/nginx:v0.1
Untagged: docker2:80/demo/nginx:v0.1
Untagged: docker2:80/demo/nginx@sha256:a3a0c4126587884f8d3090efca87f5af075d7e7ac8308cffc09a5a082d5f4760
[root@localhost ~]# docker rmi docker2:80/demo/nginx:v0.2
Untagged: docker2:80/demo/nginx:v0.2
Untagged: docker2:80/demo/nginx@sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078
[root@localhost ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE

# 拉取鏡像
[root@localhost ~]# docker pull docker2:80/demo/busybox:v0.1
v0.1: Pulling from demo/busybox
Digest: sha256:afe605d272837ce1732f390966166c2afff5391208ddd57de10942748694049d
Status: Downloaded newer image for docker2:80/demo/busybox:v0.1
docker2:80/demo/busybox:v0.1
[root@localhost ~]# docker pull docker2:80/demo/nginx:v0.1
v0.1: Pulling from demo/nginx
Digest: sha256:a3a0c4126587884f8d3090efca87f5af075d7e7ac8308cffc09a5a082d5f4760
Status: Downloaded newer image for docker2:80/demo/nginx:v0.1
docker2:80/demo/nginx:v0.1
[root@localhost ~]# docker pull docker2:80/demo/nginx:v0.2
v0.2: Pulling from demo/nginx
Digest: sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078
Status: Downloaded newer image for docker2:80/demo/nginx:v0.2
docker2:80/demo/nginx:v0.2
[root@localhost ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
docker2:80/demo/busybox         v0.1                83aa35aa1c79        5 days ago          1.22MB
docker2:80/demo/nginx           v0.1                8a2fb25a19f5        11 months ago       16MB
docker2:80/demo/nginx           v0.2                295c7be07902        11 months ago       109MB

7):在harbor web頁面可以進行很多實用的操作

如:給鏡像打標簽、復制鏡像、刪除鏡像等;

8):控制harbor服務

[root@localhost ~]# cd /data/harbor/
# 通過docker-compose命令對harbor進行控制
# 暫停harbor服務
[root@localhost harbor]# docker-compose pause
Pausing harbor-log         ... done
Pausing registry           ... done
Pausing harbor-adminserver ... done
Pausing harbor-db          ... done
Pausing redis              ... done
Pausing harbor-core        ... done
Pausing harbor-portal      ... done
Pausing nginx              ... done

# 停止harbor服務
[root@localhost harbor]# docker-compose stop
Stopping nginx              ... done
Stopping harbor-portal      ... done
Stopping harbor-core        ... done
Stopping redis              ... done
Stopping harbor-db          ... done
Stopping harbor-adminserver ... done
Stopping registry           ... done
Stopping harbor-log         ... done

# 開啟harbor服務
[root@localhost harbor]# docker-compose start
Starting log         ... done
Starting registry    ... done
Starting registryctl ... done
Starting postgresql  ... done
Starting adminserver ... done
Starting core        ... done
Starting portal      ... done
Starting redis       ... done
Starting jobservice  ... done
Starting proxy       ... done


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM