安装docker-compose
[root@docker ~]# wget -c https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64
[root@docker ~]# mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
[root@docker ~]# chmod a+x /usr/local/bin/docker-compose
[root@docker ~]# docker-compose --version
docker-compose version 1.25.5, build 8a1c60f6
安装harbor
- 下载解压安装包
[root@docker ~]# wget -c https://github.com/goharbor/harbor/releases/download/v2.0.0/harbor-offline-installer-v2.0.0.tgz
[root@docker ~]# tar xf harbor-offline-installer-v2.0.0.tgz -C /usr/local/
- 编写yaml文件
[root@docker ~]# cd /usr/local/harbor/
[root@docker harbor]# cp harbor.yml.tmpl harbor.yml
- 修改配置文件
[root@docker harbor]# vim harbor.yml
hostname: 192.168.149.134
将主机名改为自己的ip
# https related config
#https: 这里没做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
harbor_admin_password: xialuo123 这里是web界面的密码,可以自行修改
- 执行脚本
[root@docker harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.7
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.25.5
[Step 2]: loading Harbor images ...
......
Creating harbor-log ... done
Creating harbor-portal ... done
Creating harbor-db ... done
Creating redis ... done
Creating registry ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating harbor-jobservice ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.---- 这里就说明安装成功了
用户名:admin
登录
[root@docker ~]# vim /etc/docker/daemon.json
添加如下:
{"insecure-registries": ["192.168.149.134:80"]}
[root@docker ~]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 192.168.149.134 --containerd=/run/containerd/containerd.sock
- 重启服务
[root@docker ~]# systemctl daemon-reload && systemctl restart docker
- 登录验证
[root@docker harbor]# docker login 192.168.149.134 -u admin -p xialuo123
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
- 推拉镜像
上传镜像
[root@docker ~]# docker tag xialuo/nginx:v0.2 192.168.149.134/xialuo/nginx:v0.2
[root@docker ~]# docker push 192.168.149.134/xialuo/nginx:v0.2
The push refers to repository [192.168.149.134/xialuo/nginx]
bc664d5147fb: Pushed
2653d992f4ef: Pushed
v0.2: digest: sha256:6a8f341d26ef7a122d3836827926488a4a0176edafaf4a3da371434af3d29d9e size: 741