Docker学习—Docker Harbor的安装配置

Docker Harbor的安装配置

Docker Harbor是由VMware公司的中国团队开发的。私有的docker镜像仓库。Harbor是一个开放源代码可信云本机注册表项目,用于存储,签名和扫描内容。Harbor通过添加 用户通常需要的功能(例如安全性,身份和管理)扩展了开源Docker Distribution。使注册表更 接近于构建和运行环境可以提高图像传输效率。Harbor支持在注册表之间复制映像,还提供高级 安全功能,例如用户管理,访问控制和活动审核。

docker的安装

https://docs.docker.com/engine/install/centos/

一、卸载旧版本

 yum remove docker \
            docker-client \
            docker-client-latest \
            docker-common \
            docker-latest \
            docker-latest-logrotate \
            docker-logrotate \
            docker-engine

二、安装yum-utils包

yum install -y yum-utils

三、设置docker镜像库(国内阿里云)

yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

四、更新yum软件包索引

yum makecache fast

五、安装引擎

(-ce 社区版) (-e 企业版(付费))

yum -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin

六、启动docker服务

systemctl start docker

 

docker-compose的安装部署

https://docs.docker.com/compose/install/linux/

一、下载并安装Compose CLI插件

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

二、对二进制文件应用可执行权限

chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

三、选择为所有用户安装Compose

cp $DOCKER_CONFIG/cli-plugins/docker-compose /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

四、查看Compose版本

[root@docker-2 ~]# docker compose version
Docker Compose version v2.16.0
[root@docker-2 ~]# docker-compose version
Docker Compose version v2.16.0

 

harbor的下载和部署

https://github.com/goharbor/harbor/releases/tag/v2.1.0

一、上传下载解压压缩包

[root@docker-2 harbor]# ls
harbor-offline-installer-v2.1.0.tgz
[root@docker-2 harbor]# tar xf harbor-offline-installer-v2.1.0.tgz
[root@docker-2 harbor]# ls
harbor  harbor-offline-installer-v2.1.0.tgz
[root@docker-2 harbor]# cd harbor/
[root@docker-2 harbor]# ls
common  common.sh  docker-compose.yml  harbor.v2.1.0.tar.gz  harbor.yml  install.sh  LICENSE  prepare

二、调整配置

从harbor.yml.tmpl复制一个harbor.yml,然后修改前面几行,自定义Hostname,port,禁用https,设置管理员密码。

# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
# 指定主机ip地址
hostname: 192.168.220.101

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  # 指定8089端口
  port: 8089

# 禁用https
# 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

# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
#   # set enabled to true means internal tls is enabled
#   enabled: true
#   # put your cert and key files on dir
#   dir: /etc/harbor/tls/internal

# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433

# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
# 已将密码修改为zjx12345
harbor_admin_password: zjx12345

三、安装并启动

./install.sh

[Step 0]: checking if docker is installed ...
 
Note: docker version: 20.10.16
 
[Step 1]: checking docker-compose is installed ...
 
Note: docker-compose version: 2.16.0
 
[Step 2]: loading Harbor images ...
Loaded image: goharbor/clair-adapter-photon:v2.1.0
Loaded image: goharbor/trivy-adapter-photon:v2.1.0
Loaded image: goharbor/harbor-registryctl:v2.1.0
Loaded image: goharbor/harbor-log:v2.1.0
Loaded image: goharbor/harbor-portal:v2.1.0
Loaded image: goharbor/harbor-db:v2.1.0
Loaded image: goharbor/nginx-photon:v2.1.0
Loaded image: goharbor/prepare:v2.1.0
Loaded image: goharbor/harbor-jobservice:v2.1.0
Loaded image: goharbor/redis-photon:v2.1.0
Loaded image: goharbor/registry-photon:v2.1.0
Loaded image: goharbor/notary-server-photon:v2.1.0
Loaded image: goharbor/notary-signer-photon:v2.1.0
Loaded image: goharbor/clair-photon:v2.1.0
Loaded image: goharbor/chartmuseum-photon:v2.1.0
Loaded image: goharbor/harbor-core:v2.1.0
 
 
[Step 3]: preparing environment ...
 
[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/software/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
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/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
 
 
 
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis         ... done
Creating harbor-portal ... done
Creating registry      ... done
Creating registryctl   ... done
Creating harbor-db     ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----

四、查看镜像和容器,并且登录

[root@docker-2 harbor]# docker images
REPOSITORY                                         TAG          IMAGE ID       CREATED         SIZE
java-demo                                          v1.0         a7a0b5bb245a   5 months ago    321MB
registry.cn-qingdao.aliyuncs.com/zjxzwp/myubuntu   zjxzwp5.20   a7a0b5bb245a   5 months ago    321MB
nginx                                              latest       605c77e624dd   14 months ago   141MB
tomcat                                             latest       fb5657adc892   14 months ago   680MB
openjdk                                            8-jdk-slim   9afd0fe33df7   14 months ago   296MB
redis                                              latest       7614ae9453d1   14 months ago   113MB
mysql                                              5.7          c20987f18b13   14 months ago   448MB
ubuntu                                             latest       ba6acccedd29   17 months ago   72.8MB
hello-world                                        latest       feb5d9fea6a5   17 months ago   13.3kB
centos                                             7            eeb6ee3f44bd   18 months ago   204MB
goharbor/chartmuseum-photon                        v2.1.0       5bad3dce5fd5   2 years ago     172MB
goharbor/redis-photon                              v2.1.0       45fa455a8eeb   2 years ago     68.7MB
goharbor/trivy-adapter-photon                      v2.1.0       9b443d147b3d   2 years ago     106MB
goharbor/clair-adapter-photon                      v2.1.0       cee42542dfb2   2 years ago     57.9MB
goharbor/clair-photon                              v2.1.0       9741a40b433c   2 years ago     167MB
goharbor/notary-server-photon                      v2.1.0       e20ff73edec7   2 years ago     139MB
goharbor/notary-signer-photon                      v2.1.0       2b783b793805   2 years ago     136MB
goharbor/harbor-registryctl                        v2.1.0       98f466a61ebb   2 years ago     132MB
goharbor/registry-photon                           v2.1.0       09c818fabdd3   2 years ago     80.1MB
goharbor/nginx-photon                              v2.1.0       470ffa4a837e   2 years ago     40.1MB
goharbor/harbor-log                                v2.1.0       402802990707   2 years ago     82.1MB
goharbor/harbor-jobservice                         v2.1.0       ff65bef832b4   2 years ago     165MB
goharbor/harbor-core                               v2.1.0       26047bcb9ff5   2 years ago     147MB
goharbor/harbor-portal                             v2.1.0       5e97d5e230b9   2 years ago     49.5MB
goharbor/harbor-db                                 v2.1.0       44c0be92f223   2 years ago     164MB
goharbor/prepare                                   v2.1.0       58d0e7cee8cf   2 years ago     160MB
raesene/bwapp                                      latest       8be28fba48ec   7 years ago     441MB
[root@docker-2 harbor]# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED        STATUS                   PORTS                                       NAMES
dc030f2ca8ed   goharbor/harbor-jobservice:v2.1.0    "/harbor/entrypoint.…"   16 hours ago   Up 5 minutes (healthy)                                               harbor-jobservice
d99c0f9d0bd1   goharbor/nginx-photon:v2.1.0         "nginx -g 'daemon of…"   16 hours ago   Up 5 minutes (healthy)   0.0.0.0:8089->8080/tcp, :::8089->8080/tcp   nginx
5d4445be4c15   goharbor/harbor-core:v2.1.0          "/harbor/entrypoint.…"   16 hours ago   Up 5 minutes (healthy)                                               harbor-core
26368c88f224   goharbor/harbor-registryctl:v2.1.0   "/home/harbor/start.…"   16 hours ago   Up 5 minutes (healthy)                                               registryctl
b28c930c7dfa   goharbor/harbor-portal:v2.1.0        "nginx -g 'daemon of…"   16 hours ago   Up 5 minutes (healthy)                                               harbor-portal
a1f7a0950ba2   goharbor/harbor-db:v2.1.0            "/docker-entrypoint.…"   16 hours ago   Up 5 minutes (healthy)                                               harbor-db
aa965cfa3337   goharbor/registry-photon:v2.1.0      "/home/harbor/entryp…"   16 hours ago   Up 5 minutes (healthy)                                               registry
6873e42baa39   goharbor/redis-photon:v2.1.0         "redis-server /etc/r…"   16 hours ago   Up 5 minutes (healthy)                                               redis
9cb99ab21317   goharbor/harbor-log:v2.1.0           "/bin/sh -c /usr/loc…"   16 hours ago   Up 2 hours (healthy)     127.0.0.1:1514->10514/tcp                   harbor-log

在这里插入图片描述
 

harbor的使用

一、harbor用户的创建

在这里插入图片描述
二、harbor项目的创建

在这里插入图片描述
三、修改/etc/docker/daemon.json配置

{
	  "insecure-registries": ["192.168.220.101:8089"]
}

四、在其他主机登录用户

09:02:14[root@zjx520 ~]# docker login 192.168.220.101:8089
Authenticating with existing credentials...
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

#因为此前已经输入过账号密码,所有无需再输入

五、查看镜像和容器

09:40:14[root@zjx520 ~]# docker images
REPOSITORY                                TAG       IMAGE ID       CREATED         SIZE
192.168.220.101:8089/zhuwenpei/zwpnginx   9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                  9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                  1.23.3    a91ecb115947   2 days ago      613MB
zjxbusybox                                1.0       d341978bf9d6   3 days ago      4.87MB
zjx-centos                                7         61d6f478b8fe   4 days ago      458MB
nginx                                     latest    3f8a00f137a0   4 weeks ago     142MB
mysql                                     5.7.39    eb175b0743cc   5 months ago    433MB
centos                                    7         eeb6ee3f44bd   18 months ago   204MB
09:41:35[root@zjx520 ~]# docker tag zjxbusybox:1.0 192.168.220.101:8089/zhuwenpei/zjxbusybox:1.0
09:42:21[root@zjx520 ~]# docker images
REPOSITORY                                  TAG       IMAGE ID       CREATED         SIZE
192.168.220.101:8089/zhuwenpei/zwpnginx     9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                    9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                    1.23.3    a91ecb115947   2 days ago      613MB
192.168.220.101:8089/zhuwenpei/zjxbusybox   1.0       d341978bf9d6   3 days ago      4.87MB
zjxbusybox                                  1.0       d341978bf9d6   3 days ago      4.87MB
zjx-centos                                  7         61d6f478b8fe   4 days ago      458MB
nginx                                       latest    3f8a00f137a0   4 weeks ago     142MB
mysql                                       5.7.39    eb175b0743cc   5 months ago    433MB
centos                                      7         eeb6ee3f44bd   18 months ago   204MB

六、上传镜像

09:44:01[root@zjx520 ~]# docker push 192.168.220.101:8089/zhuwenpei/zjxbusybox:1.0
The push refers to repository [192.168.220.101:8089/zhuwenpei/zjxbusybox]
615e2001e84c: Pushed 
bec9aebb8f80: Pushed 
b64792c17e4a: Pushed 
1.0: digest: sha256:a40c88fbf2c56643015b0ed5734e9901011d8bfe9c41413a3fc4a4bfff2519e6 size: 942

在这里插入图片描述
七、拉取镜像

# 首先确定/etc/docker/daemon.json文件,然后再登录即可

09:50:55[root@zjx520 ~]# docker images
REPOSITORY                                TAG       IMAGE ID       CREATED         SIZE
192.168.220.101:8089/zhuwenpei/zwpnginx   9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                  9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                  1.23.3    a91ecb115947   2 days ago      613MB
zjxbusybox                                1.0       d341978bf9d6   3 days ago      4.87MB
zjx-centos                                7         61d6f478b8fe   4 days ago      458MB
nginx                                     latest    3f8a00f137a0   4 weeks ago     142MB
mysql                                     5.7.39    eb175b0743cc   5 months ago    433MB
centos                                    7         eeb6ee3f44bd   18 months ago   204MB
09:51:01[root@zjx520 ~]# docker pull 192.168.220.101:8089/zhuwenpei/zjxbusybox:1.0
1.0: Pulling from zhuwenpei/zjxbusybox
Digest: sha256:a40c88fbf2c56643015b0ed5734e9901011d8bfe9c41413a3fc4a4bfff2519e6
Status: Downloaded newer image for 192.168.220.101:8089/zhuwenpei/zjxbusybox:1.0
192.168.220.101:8089/zhuwenpei/zjxbusybox:1.0
09:51:29[root@zjx520 ~]# docker images
REPOSITORY                                  TAG       IMAGE ID       CREATED         SIZE
192.168.220.101:8089/zhuwenpei/zwpnginx     9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                    9.22      b41dc67384e1   2 days ago      613MB
zjxnginx                                    1.23.3    a91ecb115947   2 days ago      613MB
192.168.220.101:8089/zhuwenpei/zjxbusybox   1.0       d341978bf9d6   3 days ago      4.87MB
zjxbusybox                                  1.0       d341978bf9d6   3 days ago      4.87MB
zjx-centos                                  7         61d6f478b8fe   4 days ago      458MB
nginx                                       latest    3f8a00f137a0   4 weeks ago     142MB
mysql                                       5.7.39    eb175b0743cc   5 months ago    433MB
centos                                      7         eeb6ee3f44bd   18 months ago   204MB
  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值