目录
5. 移除 Harbor 服务容器同时保留镜像数据/数据库,并进行迁移
6. 如需重新部署,需要移除 Harbor 服务容器全部数据
一、如何搭建本地的私有仓库
1.首先下载registry
[root@docker ~]# docker pull registry
[root@docker ~]# docker images
然后编辑加速器文本
[root@docker ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://n1x922iy.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.80.115:5000"]
}
[root@docker ~]# systemctl restart docker.service
然后再运行registry
[root@docker ~]# docker run -itd -v /data/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f281d844638e registry:latest "/entrypoint.sh /etc…" 5 seconds ago Up 5 seconds 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry
2、再为镜像打标签
[root@docker ~]# docker tag centos:7 192.168.80.115:5000/centos:test1
[root@docker ~]# docker images
3.上传到私有仓库
[root@localhost docker]# docker push 192.168.234.210:5000/centos:v1
The push refers to repository [192.168.234.210:5000/centos]
174f56854903: Pushed
v1: digest: sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f size: 529
4、列出私有仓库的所有镜像
[root@localhost docker]# curl http://192.168.234.210:5000/v2/_catalog
{"repositories":["centos"]}
5、列出私有仓库有Centos镜像有哪些tag
[root@localhost docker]# curl http://192.168.234.210:5000/v2/centos/tags/list
{"name":"centos","tags":["v1"]}
[root@localhost docker]#
6、先删除原有的Centos的镜像,再测试私有仓库下载、
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 75ef5b734af4 12 months ago 25.4MB
192.168.234.210:5000/centos v1 eeb6ee3f44bd 3 years ago 204MB
centos 7 eeb6ee3f44bd 3 years ago 204MB
[root@localhost docker]# docker rmi -f eeb6ee3f44bd
Untagged: 192.168.234.210:5000/centos:v1
Untagged: 192.168.234.210:5000/centos@sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f
Untagged: centos:7
Untagged: centos@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4
Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9
Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 75ef5b734af4 12 months ago 25.4MB
[root@localhost docker]# docker pull 192.168.234.210:5000/centos:v1
v1: Pulling from centos
2d473b07cdd5: Pull complete
Digest: sha256:dead07b4d8ed7e29e98de0f4504d87e8880d4347859d839686a31da35a3b532f
Status: Downloaded newer image for 192.168.234.210:5000/centos:v1
192.168.234.210:5000/centos:v1
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 75ef5b734af4 12 months ago 25.4MB
192.168.234.210:5000/centos v1 eeb6ee3f44bd 3 years ago 204MB
二、什么是harbor(特性,构成,架构的数据流向)
2.1什么是Harbor
Harbor 是 VMware 公司开源的企业级 Docker Registry 项目,其目标是帮助用户迅速搭建一个企业级的 Docker Registry 服务。
Harbor以 Docker 公司开源的 Registry 为基础,提供了图形管理 UI 、基于角色的访问控制(Role Based AccessControl) 、AD/LDAP 集成、以及审计日志(Auditlogging) 等企业用户需求的功能,同时还原生支持中文。
Harbor 的每个组件都是以 Docker 容器的形式构建的,使用 docker-compose 来对它进行部署。用于部署 Harbor 的 docker-compose 模板位于 harbor/docker-compose.yml。
总之:harbor可以理解是一个储存镜像的仓库
2.2 harbor的特性
1、基于角色控制&#x