1、首先安装docker
2、安装docker-compose docker编排工具
sudocurl-L"https://github.com/docker/compose/releases/download/v2.23.2/docker-compose-$(uname -s)-$(uname -m)"-o /usr/local/bin/docker-compose
其中v2.23.2 为版本号,可自定义版本
3、授权可执行
chmod-X docker-compose
测试:
docker-compose --version
4、下载harbor
wgethttps://github.com/goharbor/harbor/releases/download/v2.9.0/harbor-online-installer-v2.9.0.tgz
tar -zxvf harbor-online-installer-v2.9.0.tgz
cd harbor
可直接下载好,然后导入进去
5、更改配置文件
hostname: 172.20.221.237
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 8087
# https related config
#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
#certificate: /your/certificate/path
#private_key: /your/private/key/path
修改配置:hostname
禁用https: 相关
可选修改:密码:harbor_admin_password
6、生成各个组件的配置
[root@iZm5ejdoz4olqok4sz22dgZ harbor]# ./prepare
此处会拉取镜像并且会创建多个文件夹
7、启动执行harbor
./install.sh
看到表示成功
✔ ----Harbor has been installed and started successfully.----
8、使用docker推送镜像到私有仓库
- 因为docker 默认支持的是https的请求,搭建的harbor环境是http的所以直接推送会有问题。
- 需要修改docker的配置文件
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
修改为:IP为自己实际Ip
ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=47.105.38.27 --containerd=/run/containerd/containerd.sock
再次使用docker登录
docker login -u admin -p Harbor12345 http://47.105.38.27:8087
提示:成功
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
9、测试镜像推送
自定义一个自己的镜像,从harbor上复制镜像推送的命令
docker tag SOURCE_IMAGE[:TAG] 172.20.221.237:8087/rdb/REPOSITORY[:TAG]
docker push 172.20.221.237:8087/rdb/REPOSITORY[:TAG]
改为自己的实际镜像及地址:
docker tag ng:my-test 47.105.38.27:8087/rdb/ng:my-test
docker push 47.105.38.27:8087/rdb/ng:my-test