Docker搭建私有镜像仓库 Harbro

摘要:Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,harbor使用的是官方的docker registry(v2命名是distribution)服务去完成。harbor在docker distribution的基础上增加了一些安全、访问控制、管理的功能以满足企业对于镜像仓库的需求。安装Harbor之前需要安装docker

一、安装Docker Compose

1.从github仓库中拉取 Docker Compose 版本 1.22.0
bash 复制代码
curl -L "https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2.对二进制文件应用可执行权限
bash 复制代码
chmod +x /usr/local/bin/docker-compose 
3.查看docker-compose是否安装成功
bash 复制代码
[root@node ~]# docker-compose --version
Docker Compose version v2.20.3

二、安装docker harbor

1.下载 harbor 的安装包(建议使用本地下载上传比较快一点)
bash 复制代码
wget https://github.com/goharbor/harbor/releases/download/v2.8.4/harbor-offline-installer-v2.8.4.tgz
2.下载完后进行解压
bash 复制代码
tar -xvf harbor-offline-installer-v2.8.4.tgz -C /usr/local/
3.编辑配置文件
bash 复制代码
[root@node ~]# cd /usr/local/harbor/
# 复制一份harbor的配置文件并改名harbor.yml
[root@node harbor]# cp harbor.yml.tmpl harbor.yml
# vim进入配置文件
[root@node harbor]# vim harbor.yml
hostname: 39.101.73.202          #这里配置的监听地址,也可以是域名
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 8000			#这里配置监听端口(没有配置证书启动后会报错,再13行-18行)
4.安装harbor
bash 复制代码
# Harbor安装环境预处理,安装依赖项、设置权限等
[root@node harbor]# ./prepare 
# 安装并启动Harbor
[root@node harbor]# ./install.sh
# 检查是否安装成功(应该是启动9个容器)要在harbor目录下操作,否则docker-compose会有问题;
[root@node harbor]# docker-compose ps -a
NAME                IMAGE                                COMMAND                  SERVICE             CREATED             STATUS                             PORTS
harbor-core         goharbor/harbor-core:v2.8.4          "/harbor/entrypoint...."   core                29 seconds ago      Up 26 seconds (health: starting)   
harbor-db           goharbor/harbor-db:v2.8.4            "/docker-entrypoint...."   postgresql          29 seconds ago      Up 27 seconds (health: starting)   
harbor-jobservice   goharbor/harbor-jobservice:v2.8.4    "/harbor/entrypoint...."   jobservice          29 seconds ago      Up 21 seconds (health: starting)   
harbor-log          goharbor/harbor-log:v2.8.4           "/bin/sh -c /usr/loc..."   log                 29 seconds ago      Up 28 seconds (health: starting)   127.0.0.1:1514->10514/tcp
harbor-portal       goharbor/harbor-portal:v2.8.4        "nginx -g 'daemon of..."   portal              29 seconds ago      Up 27 seconds (health: starting)   
nginx               goharbor/nginx-photon:v2.8.4         "nginx -g 'daemon of..."   proxy               29 seconds ago      Up 25 seconds (health: starting)   0.0.0.0:8000->8080/tcp, :::8000->8080/tcp
redis               goharbor/redis-photon:v2.8.4         "redis-server /etc/r..."   redis               29 seconds ago      Up 27 seconds (health: starting)   
registry            goharbor/registry-photon:v2.8.4      "/home/harbor/entryp..."   registry            29 seconds ago      Up 27 seconds (health: starting)   
registryctl         goharbor/harbor-registryctl:v2.8.4   "/home/harbor/start...."   registryctl         29 seconds ago      Up 27 seconds (health: starting)   
5.启动harbor
bash 复制代码
[root@node harbor]# docker-compose down					#停止harbor
[root@node harbor]# docker-compose up -d				#启动harbor
6.访问harbor页面

访问地址:(ip:端口)39.101.73.202:8000 用户名:admin 密码:Harbor12345 登录进入;

7.修改 docker 配置
bash 复制代码
vim /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://ggsypcee.mirror.aliyuncs.com"],
  "insecure-registries": ["39.101.73.202:8000"]
}
# 重启docker和harbor容器
[root@node harbor]# systemctl restart docker
[root@node harbor]# docker-compose up -d

# docker登录方式
[root@node harbor]# docker login 39.101.73.202:8000
# 或者
[root@node harbor]# docker login -uadmin -pHarbor12345 39.101.73.202:8000
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
相关推荐
PyAIGCMaster14 分钟前
ubuntu装P104驱动
linux·运维·ubuntu
奈何不吃鱼14 分钟前
【Linux】ubuntu依赖安装的各种问题汇总
linux·运维·服务器
icy、泡芙16 分钟前
T527-----音频调试
linux·驱动开发·音视频
aherhuo20 分钟前
kubevirt网络
linux·云原生·容器·kubernetes
zzzhpzhpzzz28 分钟前
Ubuntu如何查看硬件型号
linux·运维·ubuntu
蜜獾云30 分钟前
linux firewalld 命令详解
linux·运维·服务器·网络·windows·网络安全·firewalld
陌北v132 分钟前
Docker Compose 配置指南
运维·docker·容器·docker-compose
只会copy的搬运工1 小时前
Jenkins 持续集成部署——Jenkins实战与运维(1)
运维·ci/cd·jenkins
catoop1 小时前
K8s 无头服务(Headless Service)
云原生·容器·kubernetes
o(╥﹏╥)1 小时前
linux(ubuntu )卡死怎么强制重启
linux·数据库·ubuntu·系统安全