docker 镜像仓库Harbor

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 镜像仓库Harbor相关的知识,希望对你有一定的参考价值。

企业级镜像仓库Harbor

Harbor概述

Habor是由VMWare公司开源的容器镜像仓库。事实上,Habor是在Docker Registry上进行了相应的
企业级扩展,从而获得了更加广泛的应用,这些新的企业级特性包括:管理用户界面,基于角色的访
问控制 ,AD/LDAP集成以及审计日志等,足以满足基本企业需求。
官方地址:https://vmware.github.io/harbor/cn/

技术分享图片

安装
1、解压
[[email protected] tools]# tar xf harbor-offline-installer-v1.6.1.tgz

2、修改配置文件(2个地方)
[[email protected] harbor]# vi harbor.cfg
(1)hostname
hostname = 192.168.1.13
(2)密码
harbor_admin_password = 123456

docker-compose:单机编排,批量管理多个容器
[[email protected] tools]# mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
[[email protected] tools]# chmod +x /usr/bin/docker-compose

执行:

[[email protected] harbor]# ./prepare 
Generated and saved secret to file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.

安装:
[[email protected] harbor]# ./install.sh
技术分享图片

启动:
[[email protected] harbor]# docker-compose up -d

查看状态(up状态就可以访问了):
技术分享图片

访问:
http://192.168.1.13/harbor/sign-in

用户名:admin 密码:123456
技术分享图片

新建用户(密码满足复杂性):
技术分享图片

讲用户赋予哪个项目权限
以下是公开的项目,任意下载,但是上传需要用户登录
技术分享图片

指定用户
技术分享图片

将构建的镜像都上传到这个项目中:
[[email protected] harbor]# docker tag tomcat:v8.5.32 192.168.1.13/library/tomcat:v8.5.32

需要添加可信任,因为是http访问
[[email protected] harbor]# vi /etc/docker/daemon.json

{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],
"insecure-registries":["192.168.1.13"]
}

重启docker才生效
[[email protected] harbor]# systemctl restart docker
[[email protected] harbor]# docker-compose up -d

需要登录才能把镜像推入到仓库
[[email protected] harbor]# docker login 192.168.1.13
Username: jacker
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

把镜像推送到仓库
[[email protected] harbor]# docker push 192.168.1.13/library/tomcat:v8.5.32

推入成功:
技术分享图片

推入nginx:
[[email protected] harbor]# docker tag nginx:v1.15 192.168.1.13/library/nginx:v1.15
[[email protected] harbor]# docker push 192.168.1.13/library/nginx:v1.15

推入php
[[email protected] harbor]# docker tag php:v5.6.32 192.168.1.13/library/php:v5.6.32
[[email protected] harbor]# docker push 192.168.1.13/library/php:v5.6.32

总结:
1、配置http镜像仓库可信任
vi /etc/docker/daemon.json
{"insecure-registries":["reg.ctnrs.com"]}
systemctl restart docker
2、打标签
docker tag centos:6 reg.ctnrs.com/library/centos:6
3、上传
docker push reg.ctnrs.com/library/centos:6
4、下载
docker pull reg.ctnrs.com/library/centos:6

技术分享图片

以上是关于docker 镜像仓库Harbor的主要内容,如果未能解决你的问题,请参考以下文章

Linux系统 Docker 镜像仓库Harbor

docker镜像仓库

离线手动部署docker镜像仓库——harbor仓库

使用Harbor搭建企业级私有docker仓库

Docker学习记录 - 构建私有镜像仓库 - harbor

Docker--Harbor私有仓库