docker-harbor2.2.1安装

2021-04-25

  • 1、安装docker 参考:https://www.jianshu.com/p/8b471a8e5cb7
  • 2、安装部署harbor
    官方安装文档:https://goharbor.io/docs/2.2.0/install-config/
2.1、下载docker-compose和harbor离线安装包(1.7以上版本支持在线清理空间、项目限额--在测试环境无限打包的情况下,这个功能还是很实用的)
#docker-Compose 是用于定义和运行多容器 Docker 应用程序的工具,因为harbor是多个容器镜像组成,使用docker-Compose可以实现快速部署
curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
wget https://github.com/goharbor/harbor/releases/download/v2.2.1/harbor-offline-installer-v2.2.1.tgz
2.2、修改相关配置
tar -zxvf harbor-offline-installer-v2.2.1.tgz
cd harbor
cp harbor.yml.tmpl  harbor.yml
vim harbor.yml
#我这里只修改了两个参数,**注释https相关配置**,内部用http和https无所谓了,其他的使用默认参数
hostname: 192.168.2.238    #harbor访问地址
harbor_admin_password: www.123     #harbor访问密码
http.port:默认将占用80端口。 https:如果要启动https还需要配置ssl证书。改为8001
harbor_admin_password:harbor管理员密码。默认harbor_admin_password: Harbor12345。
database.password:数据库密码,默认password: root123。
data_volume:数据存放目录,默认/data。
2.3、拉取镜像、启动容器
[root@2dot238 harbor]#./prepare
[root@2dot238 harbor]# ./install.sh 
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registryctl   ... done
Creating registry      ... done
Creating harbor-portal ... done
Creating harbor-db     ... done
Creating redis         ... done
Creating harbor-core   ... done
Creating harbor-jobservice ... done
Creating nginx             ... done
✔ ----Harbor has been installed and started successfully.----
[root@2dot238 harbor]# docker ps    #可以看到各种组件都启动了
2.4、web端打开harbor界面,直接输入harbor.yml文件hostname对应的地址就行
docker-harbor2.2.1安装_第1张图片
创建项目

-----------------------------------------------------------以上部署完成------------------------------------------------------------
随便创建一个项目目录test,测试下推送和拉取镜像

2.5、打tag、推送拉取镜像
#将本地harbor镜像库地址添加到docker中,重新启动docker (使用http进行访问,类似于添加信任站点)  
1、cat >> /etc/docker/daemon.json << EOF
{
"insecure-registries" : ["192.168.2.238"]
}
EOF
[root@2dot238 harbor]# systemctl restart docker
[root@2dot238 harbor]# docker-compose restart     #重新启动所有harbor容器(需要在harbor目录中执行,他需要根据当前目录的.yaml文件来重启)
#登录harbor库,登录后账号密码默认存储在/root/.docker/config.json
2、[root@2dot238 harbor]# docker login 192.168.2.238
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
#打tag、类似于修改image名字,然后推送会根据你修改的名字去推送到指定的库
#把我们本地的镜像goharbor/harbor-exporter:v2.2.1打个标签推送到私有库上
3、[root@2dot238 harbor]# docker tag goharbor/harbor-exporter:v2.2.1  192.168.2.238/test/harbor:v0.0.1
#推送
[root@2dot238 harbor]# docker push 192.168.2.238/test/harbor:v0.0.1
The push refers to repository [192.168.2.238/test/harbor]
5233fbaf23ed: Pushed 
aad9bed872f0: Pushed 
b35ba3bc6760: Pushed 
d4b2501bd60f: Pushed 
23e1126e5547: Pushed 
v0.0.1: digest: sha256:2a575d26bc2636af447373d890f4f45f722f4f98e8084072e426a5fd5de20350 size: 1369
#拉取、先删除本地harbor:v0.0.1          docker rmi 192.168.2.238/test/harbor:v0.0.1
[root@2dot238 harbor]# docker pull 192.168.2.238/test/harbor:v0.0.1
v0.0.1: Pulling from test/harbor
Digest: sha256:2a575d26bc2636af447373d890f4f45f722f4f98e8084072e426a5fd5de20350
Status: Downloaded newer image for 192.168.2.238/test/harbor:v0.0.1
192.168.2.238/test/harbor:v0.0.1
#查看下载情况
[root@2dot238 harbor]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
192.168.2.238/test/harbor       v0.0.1    ed0b493a25d2   4 weeks ago   76.3MB
goharbor/harbor-exporter        v2.2.1    ed0b493a25d2   4 weeks ago   76.3MB
#Harbor所有容器组相关命令
# docker-compose stop   //停止Harbor
# docker-compose start  //启动Harbor
# docker-compose restart  //重启Harbor
# docker-compose ps  //Harbor容器组状态

docker-harbor2.2.1安装_第2张图片
image.png

你可能感兴趣的:(docker-harbor2.2.1安装)