前期准备
查看此机器之前有无登陆过
1
2who /var/log/wtmp
last查看linux版本
centos
1
lsb_release -a
所有linux版本
1
uname -a
RedHat,Centos
1
cat /etc/redhat-release
安装docker以及docker-compose
1 | yum update -y |
下载harbor并生成证书
1 | wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.4.tgz |
生成证书
1 | mkdir -p certs |
注意:Common Name (eg, your name or your server’s hostname)为仓库的域名.
在当前目录的certs中会生成两个证书文件
harbor.crt #客户端需要(客户端可以是远程客户端),需要将此证书复制到/etc/docker/certs.d/aliyun.harbor/harbor.crt 路径,目录不存在则需要自己创建
harbor.key
配置harbor的配置文件
编辑当前目录的harbor.cfg文件修改如下配置项:
1 | hostname = aliyun.harbor |
执行预安装命令./prepare
1 | [root@senssic harbor]# ./prepare |
使私有仓库同时支持mirro功能,编辑common/config/registry/config.yml追加
1 | proxy: |
配置完毕执行安装命令./install.sh
客户端拉取上传镜像
1.将上述生成的harbor.crt放置到客户端所在机器的/etc/docker/certs.d/aliyun.harbor/ 目录下,若目录不存在则创建.
1 | mkdir -p /etc/docker/certs.d/aliyun.harbor/ |
2.拉取测试镜像,生成tag,登陆私有镜像仓库并上传镜像
增加对于aliyun.harbor的hosts解析
编辑/etc/hosts 追加 私有仓库ip aliyun.harbor
登陆私有仓库输入用户名密码,可以在上面的harbor.cfg设置
1
2
3
4
5
6
7
8
9[root@senssic harbor]# docker login aliyun.harbor
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
[root@senssic harbor]#在harbor管理界面新建项目,项目名为test
给已存在的镜像打标签(标签前缀即为私有仓库域名,第层为上面一步创建的项目名称 test),并推送到仓库
1
2
3
4aliyun.harbor/test/showdoc中的test需要在harbor界面管理中创建,也可直接使用默认的library
docker tag registry.docker-cn.com/star7th/showdoc aliyun.harbor/test/showdoc:1.0.0
推送到远端私有仓库
docker push aliyun.harbor/test/showdoc:1.0.0拉取上传的镜像文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15[root@cjvm101 aliyun.harbor]# docker login aliyun.harbor
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
[root@cjvm101 aliyun.harbor]# docker pull aliyun.harbor/test/showdoc:1.0.0
1.0.0: Pulling from test/showdoc
ff3a5c916c92: Pull complete
2ca736d3a2d3: Pull complete
ed01bffbd8ba: Pull complete
86a241b7142f: Pull complete
2ffa2200859b: Downloading [=======>
安装过程中常用命令
1 | docker加载配置文件 |