docker镜像仓库——harbor仓库部署

docker镜像仓库——harbor仓库部署

@(k8s)
参考地址

下载地址:https://github.com/goharbor/harbor/releases
docker镜像仓库——harbor仓库部署_第1张图片

下载后解压:

[root@k8s-harbor source]# wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-online-installer-v1.9.0.tgz
--2019-09-19 16:40:39--  https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-online-installer-v1.9.0.tgz
Resolving storage.googleapis.com (storage.googleapis.com)... 172.217.24.16, 2404:6800:4008:800::2010
Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.24.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8396 (8.2K) [application/x-tar]
Saving to: ‘harbor-online-installer-v1.9.0.tgz’

100%[============================================================================================================================================================================================>] 8,396       --.-K/s   in 0.003s  

2019-09-19 16:40:39 (2.61 MB/s) - ‘harbor-online-installer-v1.9.0.tgz’ saved [8396/8396]

[root@k8s-harbor source]# tar -xvf harbor-online-installer-v1.9.0.tgz 
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/harbor.yml
[root@k8s-harbor source]# cd harbor


1. 修改harbor.cfg

vim /home/admin/harbor-install/source/harbor/harbor.cfg

docker镜像仓库——harbor仓库部署_第2张图片

2. 编辑或修改/etc/sysconfig/docker文件

[root@k8s-harbor harbor]# cat /etc/sysconfig/docker 
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false --insecure-registry=192.168.0.116:10500'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

[root@k8s-harbor harbor]# 

3. 修改后重启docker

systemctl daemon-reload
systemctl restart docker

4. 安装docker-compose

下载地址: https://github.com/docker/compose/releases/

curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
 chmod +x /usr/local/bin/docker-compose

5. 先执行prepare,再执行install.sh脚本,安装harbor仓库

docker镜像仓库——harbor仓库部署_第3张图片

cd /home/admin/harbor-install/source/harbor
./prepare

docker镜像仓库——harbor仓库部署_第4张图片

[root@k8s-harbor harbor]# ./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 18.06.3

Note: docker-compose version: 1.24.1


[Step 1]: preparing environment ...
prepare base dir is set to /home/admin/harbor-install/source/harbor
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/registry/config.yml
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir



[Step 2]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Pulling log (goharbor/harbor-log:v1.9.0)...
v1.9.0: Pulling from goharbor/harbor-log
a1fd40743af1: Already exists
aea179b49535: Pull complete
9081bb9ac872: Pull complete
3f5eda6fc7ba: Pull complete
1cf969523264: Pull complete
ccb3cdd1d532: Pull complete
830676e1a685: Pull complete
0e9c3a513ce4: Pull complete
Digest: sha256:3d9a62cf87355291547b2df831cd5f46053b9335c39d1a4fd7aff22a509d341e
Status: Downloaded newer image for goharbor/harbor-log:v1.9.0
Pulling registry (goharbor/registry-photon:v2.7.1-patch-2819-v1.9.0)...
v2.7.1-patch-2819-v1.9.0: Pulling from goharbor/registry-photon
a1fd40743af1: Already exists
4b454a6c544e: Pull complete
5c08428b0a71: Pull complete
e5617c286490: Pull complete
40689e65638f: Pull complete
e7ef0710c1dd: Pull complete
Digest: sha256:b151a16890ee2b194ec5b38fd50030cc264d9806ce4d8d93b9d2aba2f5c41a48
Status: Downloaded newer image for goharbor/registry-photon:v2.7.1-patch-2819-v1.9.0
Pulling registryctl (goharbor/harbor-registryctl:v1.9.0)...
v1.9.0: Pulling from goharbor/harbor-registryctl
a1fd40743af1: Already exists
eadafbbc0c91: Pull complete
867cca04ec2d: Pull complete
6de5017173bc: Pull complete
d21f4df3ef7c: Pull complete
5b6c5aa9f8eb: Pull complete
716fa5b4d6fd: Pull complete
Digest: sha256:4ebeed5e398d8bba727f81f287b2253cd5167b17793d7baa6df45067075e1bba
Status: Downloaded newer image for goharbor/harbor-registryctl:v1.9.0
Pulling postgresql (goharbor/harbor-db:v1.9.0)...
v1.9.0: Pulling from goharbor/harbor-db
a1fd40743af1: Already exists
91fca1938059: Pull complete
07c84ba687df: Pull complete
def1496d457d: Pull complete
3bd0a0f73699: Pull complete
b1ffef9b8549: Pull complete
23e61afb4b12: Pull complete
1b1df62745be: Pull complete
7ddf7678db69: Pull complete
Digest: sha256:f27cbb5aef6c12dd329dc2aa6fed8a4dbbfba4fac7e729d3a5584094cdaeca10
Status: Downloaded newer image for goharbor/harbor-db:v1.9.0
Pulling portal (goharbor/harbor-portal:v1.9.0)...
v1.9.0: Pulling from goharbor/harbor-portal
a1fd40743af1: Already exists
117276b1e487: Pull complete
e9eb95891e00: Pull complete
3d5be3181154: Pull complete
24a5cae1ec28: Pull complete
10e6953c5a5b: Pull complete
fc2e7fe96214: Pull complete
Digest: sha256:4da2a9f9ef09e45fa0a27d673ac5d92ebc0a56e992bf9d69825b18b545da7305
Status: Downloaded newer image for goharbor/harbor-portal:v1.9.0
Pulling redis (goharbor/redis-photon:v1.9.0)...
v1.9.0: Pulling from goharbor/redis-photon
a1fd40743af1: Already exists
1752a158322c: Pull complete
16d4cc2ca0d5: Pull complete
f4b0246b9cb8: Pull complete
996e7e3ebaf5: Pull complete
Digest: sha256:b706cc43b8489775fc33c734528722b7f9bbd902e4c5ca73232a3faf2cf27cfd
Status: Downloaded newer image for goharbor/redis-photon:v1.9.0
Pulling core (goharbor/harbor-core:v1.9.0)...
v1.9.0: Pulling from goharbor/harbor-core
a1fd40743af1: Already exists
b4da616eb0f0: Pull complete
b92d87d60aa8: Pull complete
06d98e921b4f: Pull complete
ab57a19168da: Pull complete
9113abfeab16: Pull complete
Digest: sha256:c921601629c2841621092885dd644b7977262399793a305e92f8af0d255dff55
Status: Downloaded newer image for goharbor/harbor-core:v1.9.0
Pulling jobservice (goharbor/harbor-jobservice:v1.9.0)...
v1.9.0: Pulling from goharbor/harbor-jobservice
a1fd40743af1: Already exists
1c22797c72cc: Pull complete
88f57de35b34: Pull complete
Digest: sha256:d0bdda32771de6446831705613abefa0803a79d9e7156ba42d5dd8a0cc045a98
Status: Downloaded newer image for goharbor/harbor-jobservice:v1.9.0
Pulling proxy (goharbor/nginx-photon:v1.9.0)...
v1.9.0: Pulling from goharbor/nginx-photon
a1fd40743af1: Already exists
a16e88e2365b: Pull complete
Digest: sha256:968130655bbfef99f0bf9e20b9c0ce31766f5c4c3f726f2455b286be78a04ad4
Status: Downloaded newer image for goharbor/nginx-photon:v1.9.0
Creating harbor-log ... done
Creating redis         ... done
Creating harbor-db     ... done
Creating registryctl   ... done
Creating harbor-portal ... done
Creating registry      ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done

✔ ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://192.168.0.116. 
For more details, please visit https://github.com/goharbor/harbor .

docker镜像仓库——harbor仓库部署_第5张图片

成功

在这里插入图片描述

docker镜像仓库——harbor仓库部署_第6张图片

访问页面:http://192.168.0.116:10500

docker镜像仓库——harbor仓库部署_第7张图片

输入账号密码:

admin
xxxxx2019

docker镜像仓库——harbor仓库部署_第8张图片

创建一个测试项目:

docker镜像仓库——harbor仓库部署_第9张图片

#####换另一台服务器拉取一个nginx公共镜像并推送到harbor仓库:
1、 设置

root@baknginx1:[/root]$cat /etc/sysconfig/docker |grep -v ^# | grep -v ^$
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --registry-mirror=https://fzhifedh.mirror.aliyuncs.com --insecure-registry=192.168.0.116:10500'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi
root@baknginx1:[/root]$

root@baknginx1:[/root]$cat /etc/docker/daemon.json 
{}

在这里插入图片描述

2、 拉一个公共的nginx镜像

docker pull nginx

3、 先给镜像打标签

docker tag docker.io/nginx 192.168.0.116:10500/wxd-test/t-nginx:v1

docker镜像仓库——harbor仓库部署_第10张图片

4、 推送到本地仓库

docker push docker.io/nginx 192.168.0.116:10500/wxd-test/t-nginx:v1

docker镜像仓库——harbor仓库部署_第11张图片

在页面查看
docker镜像仓库——harbor仓库部署_第12张图片

#### 安装中遇到的问题
执行./prepare时,报data_volume值必须用绝对路径,不能使用相对路径(之前写的./data)
在这里插入图片描述

docker-compose 版本过低,版本要求不低于1.18.0
docker镜像仓库——harbor仓库部署_第13张图片

docker push 的时候,报unauthorized: authentication required,需要本地docker先登录到远程harbor仓库
docker镜像仓库——harbor仓库部署_第14张图片

你可能感兴趣的:(k8s)