Harbor镜像仓库的搭建使用

1.docker-compose官方地址:https://docs.docker.com/compose/install/

2.Harbor官方地址:https://github.com/goharbor/harbor

3.安装docker-compose:

下载docker-compose:curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
赋予执行权限:chmod +x /usr/local/bin/docker-compose
软链接到/usr/bin/:ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
查看版本:docker-compose --version
docker-compose version 1.29.2, build 5becea4c

4.安装Harbor镜像仓库

下载Harbor离线包:wget https://github.com/goharbor/harbor/releases/download/v2.2.3-rc1/harbor-offline-installer-v2.2.3-rc1.tgz
解压Harbor离线包:tar xf harbor-offline-installer-v2.2.3-rc1.tgz
拷贝配置文件:cd harbor/ && cp -r harbor.yml.tmpl harbor.yml
修改配置文件,取消https,外网有证书可以开启https:vim harbor.yml

初始化配置:./prepare
安装Harbor:./install.sh

5.访问页面:http://10.200.202.83/

6.使用docker-compose对Harbor做日常管理【必须进入docker-compose.yml所在目录 cd /root/harbor/】:

查看Harbor服务状态:docker-compose ps
启动Harbor所有服务:docker-compose up -d
关闭Harbor所有服务:docker-compose stop

7.使用docker登陆Harbor镜像仓库:docker login 10.200.202.83

提示https报错,因为Harbor没有开启https,则需要修改docker配置文件,添加信任
vim /etc/docker/daemon.json

{
  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],
  "insecure-registries":["10.200.202.83"]
}

重启docker:systemctl restart docker.service 重启docker后需要检查Harbor服务状态
再次登陆Harbor镜像仓库:docker login 10.200.202.83

8.推送命令,Harbor有说明:
标记镜像:

docker tag nginx:v2 10.200.202.83/mytest/nginx:v2
docker tag tomcat:latest 10.200.202.83/mytest/tomcat:latest

推送镜像:

docker push 10.200.202.83/mytest/nginx:v2
docker push 10.200.202.83/mytest/tomcat:latest

拉取镜像仓库的镜像:

docker pull 10.200.202.83/mytest/nginx:v2

 

posted @ 2021-08-02 21:09  chenjianwen  阅读(288)  评论(0编辑  收藏  举报