docker企业级私有仓库harbor部署配置(十三)
企业级私有仓库harbor
1.安装harbor
1.1.获取harbor源码包
https://github.com/goharbor/harbor/releases/download/v2.0.1/harbor-offline-installer-v2.0.1.tgz
或者在Linux中下载
[root@docker03 ~]# wget https://github.com/goharbor/harbor/releases/download/v2.0.1/harbor-offline-installer-v2.0.1.tgz
1.2.安装harbor
安装harbor之前必须安装docker和docker-compose
[root@docker03 ~]# tar xf harbor-offline-installer-v1.5.1.tgz
[root@docker03 ~]# cd harbor/
修改harbor配置文件,只需要修改ip和密码即可
[root@docker03 harbor]# vim harbor.cfg
hostname = 192.168.81.230
harbor_admin_password = admin
[root@docker03 harbor]# ./install.sh
安装完毕截图
1.3.登录harbor
访问http://192.168.81.230/harbor/projects
2.使用harbor
docker上传镜像的镜像会上传到项目–项目名称中
2.1.新建一个而项目
项目—新建项目—项目名称----公开—确定
公开后所有人都能下载,如果不公开,只能通过登录后才能下载
2.2.上传镜像到harbor仓库中
1)将仓库地址写入到daemon.json配置文件中
由于harbor的地址是http的,因此需要将仓库地址写到daemon.json中
[root@docker01 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries": ["192.168.81.210"],
"live-restore": true,
}
不写到daemon.json会报下面的错误
Get https://192.168.81.230/v2/: dial tcp 192.168.81.230:443: connect: connection refused
2)上传镜像
1.登录harbor仓库
[root@docker01 ~]# docker login 192.168.81.230
Username: admin
Password:
2.打标签
[root@docker01 ~]# docker tag centos69_ssh_df:v3 192.168.81.230/ssh/centos69_ssh_df:v3
3.上传镜像
[root@docker01 ~]# docker push 192.168.81.230/ssh/centos69_ssh_df:v3
The push refers to repository [192.168.81.230/ssh/centos69_ssh_df]
ceae641c5606: Pushed
925f4d2d9cbc: Pushed
27d5f3e06f6e: Pushed
01dd7d64fab6: Pushed
586d863cc8b4: Pushed
b5fefd57f2f8: Pushed
aaa5621d7c01: Pushed
v3: digest: sha256:9b080c84f79411da1ebe055811a0f39d0f3a075c7bc588855e7e6e2956d2a402 size: 1777
可以看到harbor上面已经有了
点击镜像名即可进入详情
2.3.从harbor上下载镜像
1.先将镜像删除
[root@docker01 ~]# docker rmi 192.168.81.230/ssh/centos69_ssh_df:v3
2.下载镜像
[root@docker01 ~]# docker pull 192.168.81.230/ssh/centos69_ssh_df:v3
3.查看
[root@docker01 ~]# docker images | grep 230
192.168.81.230/ssh/centos69_ssh_df v3 2ccb494fa7b0 12 days ago 367MB
2.4.删除harbor上的镜像
选中镜像—删除—确定
3.harbor报错
3.1.上传镜像失败
这个报错是由于harbor有密码因此需要先登录下
[root@docker01 ~]# docker login 192.168.81.230
Username: admin
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
3.2.重启docker报错
重启docker后harbor可能会启动不起来,需要手动重启一下
[root@docker02 harbor]# docker-compose restart
Restarting nginx ... done
Restarting harbor-jobservice ... done
Restarting harbor-ui ... done
Restarting harbor-adminserver ... done
Restarting harbor-db ... done
Restarting redis ... done
Restarting registry ... done
Restarting harbor-log ... done
如果单个起不来就用docker-compose start 容器名启动即可
单独启动一个
[root@localhost harbor]# vim docker-compose.yml
搜索ui
ui:
image: vmware/harbor-ui:v1.5.1
[root@localhost harbor]# docker-compose start ui
start 后面跟的就是刚刚在docker-compose中查到的ui
如果还是访问不到harbor则重启这两个容器
[root@localhost harbor]# docker restart nginx
nginx
[root@localhost harbor]# docker restart harbor-db
4.删除harbor
彻底删除harbor,需要查下docker-compose.yaml中的volume路径,将所有的目录删除即可
目录 返回
首页