Harbor的安装与使用
目录
一、Harbor简介
1.1 什么是Harbor
1.2 主要功能
1.3 其他特性
1.4 组件与架构
1.5 使用场景
二、安装docker
2.1 导包
2.2 解压docker安装包
2.3 配置systemd管理docker
2.4 创建docker配置文件daemon.json
2.5 启动docker
2.6 安装docker-compose
三、安装Harbor
3.1 导包并解压Harbor
3.2 修改基础配置
3.3 执行安装
3.4 新增权限
3.5 登录Harbor
四、Harbor的使用
4.1 新建项目名
4.2 准备推送的镜像
4.3 推送镜像到Harbor仓库
4.4 镜像拉取
一、Harbor简介
1.1 什么是Harbor
Harbor 是 VMware 公司开源的企业级 Docker Registry 项目,其目标是帮助用户迅速搭建一个企业级的 Docker Registry 服务。
Harbor以 Docker 公司开源的 Registry 为基础,提供了图形管理 UI 、
基于角色的访问控制(Role Based AccessControl) 、AD/LDAP 集成、以及审计日志(Auditlogging) 等企业用户需求的功能,
同时还原生支持中文。
Harbor 的每个组件都是以 Docker 容器的形式构建的,使用 docker-compose 来对它进行部署。
用于部署 Harbor 的 docker-compose 模板位于 harbor/docker-compose.yml。
1.2 主要功能
镜像存储:harbor提供高效的存储管理,支持镜像的推送和拉取。
镜像复制:支持在多个harbor实例之间复制镜像,便于跨区域和跨数据中心的分发。
镜像签名:支持notary服务,对镜像进行签名和验证,确保镜像的完整性和来源可信。同时,通过docker content trust实现镜像签名,确保只有经过签名的镜像可以运行。
镜像扫描:集成了clair安全扫描器,自动扫描镜像中的漏洞,并提供详细的报告。
访问控制:提供基于角色的访问控制(RBAC),确保只有授权用户才能访问和操作镜像。
1.3 其他特性
高可用性:支持高可用部署模式,保证在生产环境中的稳定运行。
可扩展性:支持与kubernetes、docker swarm等编排工具的集成,适应大规模的容器集群管理。
审计日志:记录用户的所有操作日志,便于审计和故障排查。
系统监控:提供系统的实时监控和告警,帮助管理员及时发现和解决问题。
项目隔离:通过项目来隔离不同团队和项目的数据和资源。
配额管理:支持对项目的资源配额进行管理,防止资源滥用。
1.4 组件与架构
Harbor的每个组件都是以docker容器的形式构建的,并使用docker-compose进行部署。其架构主要包括以下组件:
1.Proxy:一个nginx的前端代理,负责将来自浏览器、docker clients的请求转发到后端不同的服务上。
2.Registry:负责存储docker镜像,并处理docker push/pull命令。由于要对用户进行访问控制,Registry会指向一个Token服务,强制用户的每次docker pull/push请求都要携带一个合法的token。
3.core services:harbor的核心功能,主要提供以下服务:
UI:提供图形化界面,帮助用户管理Registry上的镜像,并对用户进行授权。
WebHook:监听模块,为了及时获取Registry上image状态变化的情况,在Registry上配置webhook,把状态变化传递给UI模块。
Token服务:负责根据用户权限给每个Docker pull/push命令签发Token。
4.Database(harbor-db):为core services提供数据库服务,负责存储用户权限、审计日志、Docker镜像分组信息等数据。
5.Job services:主要用于镜像复制,本地镜像可以被同步到远程Harbor实例上。
6.Log collector(harbor-log):负责收集其他组件的日志到一个地方。
1.5 使用场景
Harbor适用于需要高效、安全的镜像仓库的企业用户。通过镜像复制功能,可以实现跨区域和跨数据中心的镜像分发。同时,通过镜像签名和流动扫描功能,可以确保镜像的安全性和合规性。此外,Harbor还支持与CI/CD工具集成,实现自动化镜像的构建、存储和部署。
综上所述,Harbor是一个功能强大且易用的Docker镜像仓库解决方案,适合企业在容器化环境中进行镜像管理和安全控制。
二、安装docker
准备工作,在安装Harbor前,确保docker与docker-compose已安装完毕。可以通过docker -v查看docker版本,通过docker-compose -v查看docker-compose版本信息。
docker安装包可通过阿里云官网下载所需版本的包:阿里云docker镜像。这里安装docker-19.03.9.tgz版本。
在/opt目录下,创建两个目录docker、harbor
[root@localhost ~]#:cd /opt/
[root@localhost opt]#:mkdir docker harbor
2.1 导包
其中,docker存放docker安装包,harbor存放harbor安装包。
通过xshell连接工具,直接拖入安装包,或者使用xftp传入文件。
[root@localhost opt]#:cd docker/
[root@localhost docker]#:ls
docker-19.03.9.tgz docker-compose-Linux-x86_64
[root@localhost docker]#:
2.2 解压docker安装包
[root@localhost docker]#:tar xf docker-19.03.9.tgz
[root@localhost docker]#:ls
docker docker-19.03.9.tgz docker-compose-Linux-x86_64
[root@localhost docker]#:
此时将docker目录下的所有文件移动到/usr/bin/下
[root@localhost docker]#:ls docker
containerd containerd-shim ctr docker dockerd docker-init docker-proxy runc
[root@localhost docker]#:mv docker/* /usr/bin/
[root@localhost docker]#:
2.3 配置systemd管理docker
将docker启停写入systemd管理
[root@localhost docker]#:vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s[Install]
WantedBy=multi-user.target
2.4 创建docker配置文件daemon.json
配置文件一般放在/etc/docker/daemon.json
[root@localhost docker]#:mkdir /etc/docker
[root@localhost docker]#:vim /etc/docker/daemon.json
{"registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com"],"graph": "/home/docker-data","insecure-registries": ["192.168.114.88"],"log-driver": "json-file","log-opts": {"max-size": "100m", "max-file": "3"}
}
指定镜像仓库地址
{
"registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com"],
"graph": "/home/docker-data",
"insecure-registries": ["192.168.114.88"], #允许 Docker 客户端与指定的私有镜像仓库(Registry)通过不安全的 HTTP 协议进行通信
"log-driver": "json-file",
"log-opts": {"max-size": "100m", "max-file": "3"}
}
2.5 启动docker
重新加载systemd,启动dokcer服务并设置为开机自启
[root@localhost docker]#:systemctl daemon-reload
[root@localhost docker]#:systemctl start docker
[root@localhost docker]#:systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@localhost docker]#:
此时docker安装完成,查看版本和镜像,此时未上传镜像
[root@localhost docker]#:docker -v
Docker version 19.03.9, build 9d988398e7
[root@localhost docker]#:docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost docker]#:
查看状态
2.6 安装docker-compose
移动到/usr/local/bin/下。改名为docker-compose并加执行权限。查看版本。
[root@localhost docker]#:mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
[root@localhost docker]#:chmod +x /usr/local/bin/docker-compose
[root@localhost docker]#:docker-compose -v
docker-compose version 1.29.2, build 5becea4c
[root@localhost docker]#:
三、安装Harbor
Harbor镜像仓库。准备Harbor安装包,可以去官网下载:Harbor安装包下载。
3.1 导包并解压Harbor
将Harbor放在我们指定的路径下。/opt/harbor/下,解压后有以下文件。
[root@localhost docker]#:cd /opt/harbor/
[root@localhost harbor]#:ls
common.sh harbor.v2.8.0.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
3.2 修改基础配置
各文件解释:
common.sh #安装脚本的工具脚本,提供基础函数库(如日志记录,环境检查等),供其他脚本调用。
harbor.v2.8.0.tar.gz #包含Harbor所有功能组件的镜像文件压缩包,脚本会解压此文件并加载镜像到本地docker环境。作为Harbor运行的基础容器镜像。
harbor.yml.tmpl #Harbor的核心配置文件,定义部署参数。例如hostname服务访问的主机,http/https端口及证书路径,管理员密码,数据库,存储等组件的配置。
install.sh #主安装脚本,执行操作。会检查系统依赖,docker、docker-compose。调用prepare脚本生成组件配置,加载harbor.v2.8.0.tar.gz中的镜像,通过docker-compose启动Harbor多容器服务。
LICENSE #Harbor开源许可证文件。
prepare #配置生成脚本,将Harbor.yml中的参数注入各组件的配置文件(如Nginx,数据库配置),并生成docker-compose.yml文件,定义容器间的依赖关系和网路配置。通常在修改harbor.yml后云运行,确保配置生效。
给prepare一个执行权限。将harbor.yml.tmpl改名为harbor.yml。
[root@localhost harbor]#:chmod +x prepare
[root@localhost harbor]#:mv harbor.yml.tmpl harbor.yml
修改配置文件。修改harbor服务器主机名为本地ip。注释https,使用本地http协议。端口默认80
harbor_admin_password: Harbor12345 #密码默认Harbor12345
查看修改:
[root@localhost harbor]#:grep -vE "^$|^#| #" harbor.yml
hostname: 192.168.114.88 #主机名
http: port: 80 #端口默认80,也可以修改。但docker配置文件daemon.json也要修改。
harbor_admin_password: Harbor12345 #admin用户,密码Harbor12345
database:password: root123 #数据库密码默认max_idle_conns: 100max_open_conns: 900conn_max_lifetime: 5mconn_max_idle_time: 0
data_volume: /data
trivy:ignore_unfixed: falseskip_update: falseoffline_scan: falsesecurity_check: vulninsecure: false
jobservice:max_job_workers: 10
notification:webhook_job_max_retry: 3
log:level: infolocal:rotate_count: 50rotate_size: 200Mlocation: /var/log/harbor
_version: 2.8.0
proxy:http_proxy:https_proxy:no_proxy:components:- core- jobservice- trivy
upload_purging:enabled: trueage: 168hinterval: 24hdryrun: false
cache:enabled: falseexpire_hours: 24
[root@localhost harbor]#:
3.3 执行安装
该Harbor包提供安装脚本,可一键执行安装。
[root@localhost harbor]#:chmod +x *.sh
[root@localhost harbor]#:ls
common.sh harbor.v2.8.0.tar.gz harbor.yml install.sh LICENSE prepare
[root@localhost harbor]#:./install.sh
执行安装。
[root@localhost harbor]#:./install.sh [Step 0]: checking if docker is installed ...Note: docker version: 19.03.9[Step 1]: checking docker-compose is installed ...Note: docker-compose version: 1.29.2[Step 2]: loading Harbor images ...
17d981d1fd47: Loading layer [==================================================>] 37.78MB/37.78MB
31886c65da47: Loading layer [==================================================>] 99.07MB/99.07MB
22b8b3f55675: Loading layer [==================================================>] 3.584kB/3.584kB
e0d07daed386: Loading layer [==================================================>] 3.072kB/3.072kB
192e4941b719: Loading layer [==================================================>] 2.56kB/2.56kB
ea466c659008: Loading layer [==================================================>] 3.072kB/3.072kB
0a9da2a9c15e: Loading layer [==================================================>] 3.584kB/3.584kB
b8d43ab61309: Loading layer [==================================================>] 20.48kB/20.48kB
......
......
......
prepare base dir is set to /opt/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
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dirNote: stopping existing Harbor instance ...
Removing network harbor_harbor
WARNING: Network harbor_harbor not found.[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-portal ... done
Creating registryctl ... done
Creating redis ... done
Creating harbor-db ... done
Creating registry ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.---- #出现successfully安装成功
[root@localhost harbor]#:
此时可查看镜像
[root@localhost harbor]#:docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/harbor-exporter v2.8.0 2abc02438fcf 2 years ago 97.1MB
goharbor/redis-photon v2.8.0 ef1f410f9255 2 years ago 127MB
goharbor/trivy-adapter-photon v2.8.0 724824e3559a 2 years ago 454MB
goharbor/notary-server-photon v2.8.0 d603449fe91f 2 years ago 113MB
goharbor/notary-signer-photon v2.8.0 618fc02c41bf 2 years ago 110MB
goharbor/harbor-registryctl v2.8.0 165749c6eedc 2 years ago 141MB
goharbor/registry-photon v2.8.0 8bfd12c2163d 2 years ago 78.5MB
goharbor/nginx-photon v2.8.0 cfc2401896e1 2 years ago 126MB
goharbor/harbor-log v2.8.0 f31ccc3d46f0 2 years ago 134MB
goharbor/harbor-jobservice v2.8.0 1b00a3a474e1 2 years ago 140MB
goharbor/harbor-core v2.8.0 15f4066c1707 2 years ago 164MB
goharbor/harbor-portal v2.8.0 ae18a071cdce 2 years ago 133MB
goharbor/harbor-db v2.8.0 f3d4373617a2 2 years ago 179MB
goharbor/prepare v2.8.0 daa44ccf3b06 2 years ago 170MB
查看容器
[root@localhost harbor]#:docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4cb22bf7648 goharbor/harbor-jobservice:v2.8.0 "/harbor/entrypoint.…" 2 minutes ago Up 2 minutes (healthy) harbor-jobservice
b9c545002ec4 goharbor/nginx-photon:v2.8.0 "nginx -g 'daemon of…" 2 minutes ago Restarting (1) 16 seconds ago nginx
54ee1b828406 goharbor/harbor-core:v2.8.0 "/harbor/entrypoint.…" 2 minutes ago Up 2 minutes (healthy) harbor-core
fa6e2efcb1ec goharbor/harbor-db:v2.8.0 "/docker-entrypoint.…" 2 minutes ago Up 2 minutes (healthy) harbor-db
6f85fb30d3d4 goharbor/registry-photon:v2.8.0 "/home/harbor/entryp…" 2 minutes ago Restarting (1) 17 seconds ago registry
eae53fc856f2 goharbor/redis-photon:v2.8.0 "redis-server /etc/r…" 2 minutes ago Up 2 minutes (healthy) redis
50b04371d127 goharbor/harbor-registryctl:v2.8.0 "/home/harbor/start.…" 2 minutes ago Restarting (1) 18 seconds ago registryctl
93ec1287d4b8 goharbor/harbor-portal:v2.8.0 "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes (healthy) harbor-portal
ab32e2a41620 goharbor/harbor-log:v2.8.0 "/bin/sh -c /usr/loc…" 2 minutes ago Up 2 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
此时发现有三个容器没起来,nginx,registry,registryctl。
[root@localhost harbor]#:docker-compose ps Name Command State Ports
---------------------------------------------------------------------------------------------
harbor-core /harbor/entrypoint.sh Up (healthy)
harbor-db /docker-entrypoint.sh 13 Up (healthy)
harbor-jobservice /harbor/entrypoint.sh Up (healthy)
harbor-log /bin/sh -c /usr/local/bin/ ... Up (healthy) 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up (healthy)
nginx nginx -g daemon off; Restarting
redis redis-server /etc/redis.conf Up (healthy)
registry /home/harbor/entrypoint.sh Restarting
registryctl /home/harbor/start.sh Restarting
通过查看日志发现容器中配置文件权限受限
3.4 新增权限
此时多了common和docker-compose.yml文件。
common文件通常包含Harbor安装和运行所需的共享工具脚本、配置模块或辅助文件,其作用是为其他脚本提供基础功能支持。
[root@localhost harbor]#:ls
common common.sh docker-compose.yml harbor.v2.8.0.tar.gz harbor.yml install.sh LICENSE prepare
[root@localhost harbor]#:
给common赋予777的权限 ,重启容器。
[root@localhost harbor]#:chmod 777 -R common
[root@localhost harbor]#:
[root@localhost harbor]#:docker-compose restart
Restarting harbor-jobservice ... done
Restarting nginx ... done
Restarting harbor-core ... done
Restarting harbor-db ... done
Restarting registry ... done
Restarting redis ... done
Restarting registryctl ... done
Restarting harbor-portal ... done
Restarting harbor-log ... done
[root@localhost harbor]#:docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4cb22bf7648 goharbor/harbor-jobservice:v2.8.0 "/harbor/entrypoint.…" 13 minutes ago Up 10 seconds (health: starting) harbor-jobservice
b9c545002ec4 goharbor/nginx-photon:v2.8.0 "nginx -g 'daemon of…" 13 minutes ago Up 13 seconds (health: starting) 0.0.0.0:80->8080/tcp nginx
54ee1b828406 goharbor/harbor-core:v2.8.0 "/harbor/entrypoint.…" 13 minutes ago Up 11 seconds (health: starting) harbor-core
fa6e2efcb1ec goharbor/harbor-db:v2.8.0 "/docker-entrypoint.…" 13 minutes ago Up 11 seconds (health: starting) harbor-db
6f85fb30d3d4 goharbor/registry-photon:v2.8.0 "/home/harbor/entryp…" 13 minutes ago Up 13 seconds (health: starting) registry
eae53fc856f2 goharbor/redis-photon:v2.8.0 "redis-server /etc/r…" 13 minutes ago Up 13 seconds (health: starting) redis
50b04371d127 goharbor/harbor-registryctl:v2.8.0 "/home/harbor/start.…" 13 minutes ago Up 4 seconds (health: starting) registryctl
93ec1287d4b8 goharbor/harbor-portal:v2.8.0 "nginx -g 'daemon of…" 13 minutes ago Up 13 seconds (health: starting) harbor-portal
ab32e2a41620 goharbor/harbor-log:v2.8.0 "/bin/sh -c /usr/loc…" 13 minutes ago Up 4 seconds (health: starting) 127.0.0.1:1514->10514/tcp harbor-log
[root@localhost harbor]#:
3.5 登录Harbor
在浏览器中输入Harbor地址:192.168.114.88
登录首页,输入用户名密码:admin/Harbor12345
此时访问进来了。其中library是默认的项目名。
四、Harbor的使用
4.1 新建项目名
在项目首页,新建项目名。
点击新建项目,输入项目名k8s,勾选公开。点击确定。
成功创建。此时还没有镜像,镜像仓库数为0
4.2 准备推送的镜像
这里准备镜像包,例如nginx镜像包。先通过load -i上传到docker本地。
[root@localhost harbor]#:cd /opt/
[root@localhost opt]#:mkdir images
[root@localhost opt]#:cd images/
[root@localhost images]#:rz -E #这里是在xshell里直接把nginx拖进该目录下
rz waiting to receive.
[root@localhost images]#:ls
nginx.tar
[root@localhost images]#:
上传镜像到本地。
[root@localhost images]#:docker load -i nginx.tar
2edcec3590a4: Loading layer [==================================================>] 83.86MB/83.86MB
e379e8aedd4d: Loading layer [==================================================>] 62MB/62MB
b8d6e692a25e: Loading layer [==================================================>] 3.072kB/3.072kB
f1db227348d0: Loading layer [==================================================>] 4.096kB/4.096kB
32ce5f6a5106: Loading layer [==================================================>] 3.584kB/3.584kB
d874fd2bc83b: Loading layer [==================================================>] 7.168kB/7.168kB
Loaded image: nginx:latest
[root@localhost images]#:
查看镜像。
需要将本地镜像重新命名新的镜像名,指定Harbor仓库地址和项目名。
使用tag重新命名镜像名。
[root@localhost images]#:docker tag nginx:latest 192.168.114.88/k8s/nginx:latest
镜像id相同。
4.3 推送镜像到Harbor仓库
如若推送镜像到Harbor,需要本地docker登录Harbor,才能够完成推送。
docker login ip:端口 #因为我这里默认80端口可以不加,如其他端口需要加端口号。
[root@localhost images]#:docker login 192.168.114.88
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-storeLogin Succeeded
[root@localhost images]#:
看到Login Succeded登录成功。
推送镜像到Harbor仓库。
[root@localhost images]#:docker push 192.168.114.88/k8s/nginx:latest
The push refers to repository [192.168.114.88/k8s/nginx]
d874fd2bc83b: Pushed
32ce5f6a5106: Pushed
f1db227348d0: Pushed
b8d6e692a25e: Pushed
e379e8aedd4d: Pushed
2edcec3590a4: Pushed
latest: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570
[root@localhost images]#:
在浏览器页面刷新查看,发现多了一个镜像。
点进来查看镜像
此时完成镜像的推送。
4.4 镜像拉取
把本地镜像删除。
[root@localhost images]#:docker images | grep nginx
goharbor/nginx-photon v2.8.0 cfc2401896e1 2 years ago 126MB
192.168.114.88/k8s/nginx latest 605c77e624dd 3 years ago 141MB
nginx latest 605c77e624dd 3 years ago 141MB
[root@localhost images]#:
[root@localhost images]#:
[root@localhost images]#:
[root@localhost images]#:docker rmi nginx:latest
Untagged: nginx:latest
[root@localhost images]#:docker rmi 192.168.114.88/k8s/nginx #标签是latest时。可以不加标签。
Untagged: 192.168.114.88/k8s/nginx:latest
Untagged: 192.168.114.88/k8s/nginx@sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
Deleted: sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
Deleted: sha256:b625d8e29573fa369e799ca7c5df8b7a902126d2b7cbeb390af59e4b9e1210c5
Deleted: sha256:7850d382fb05e393e211067c5ca0aada2111fcbe550a90fed04d1c634bd31a14
Deleted: sha256:02b80ac2055edd757a996c3d554e6a8906fd3521e14d1227440afd5163a5f1c4
Deleted: sha256:b92aa5824592ecb46e6d169f8e694a99150ccef01a2aabea7b9c02356cdabe7c
Deleted: sha256:780238f18c540007376dd5e904f583896a69fe620876cabc06977a3af4ba4fb5
Deleted: sha256:2edcec3590a4ec7f40cf0743c15d78fb39d8326bc029073b41ef9727da6c851f
查看镜像,上传的nginx的镜像被删除。
从Harbor上拉取镜像。
[root@localhost images]#:docker pull 192.168.114.88/k8s/nginx
Using default tag: latest
latest: Pulling from k8s/nginx
a2abf6c4d29d: Pull complete
a9edb18cadd1: Pull complete
589b7251471a: Pull complete
186b1aaa4aa6: Pull complete
b4df32aa5a72: Pull complete
a0bcbecc962e: Pull complete
Digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
Status: Downloaded newer image for 192.168.114.88/k8s/nginx:latest
192.168.114.88/k8s/nginx:latest
也可以从Harbor上复制,粘贴到命令行拉取。
#先把当前的nginx镜像删除
[root@localhost images]#:docker rmi 192.168.114.88/k8s/nginx
点击复制。
粘贴到命令行下,执行。
查看镜像,发现标签tag是<none>
修改标签,将<none>修改为latest,指定镜像id修改。
docker tag 605c77e624dd 192.168.114.88/k8s/nginx
[root@localhost images]#:docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
goharbor/harbor-exporter v2.8.0 2abc02438fcf 2 years ago 97.1MB
goharbor/redis-photon v2.8.0 ef1f410f9255 2 years ago 127MB
goharbor/trivy-adapter-photon v2.8.0 724824e3559a 2 years ago 454MB
goharbor/notary-server-photon v2.8.0 d603449fe91f 2 years ago 113MB
goharbor/notary-signer-photon v2.8.0 618fc02c41bf 2 years ago 110MB
goharbor/harbor-registryctl v2.8.0 165749c6eedc 2 years ago 141MB
goharbor/registry-photon v2.8.0 8bfd12c2163d 2 years ago 78.5MB
goharbor/nginx-photon v2.8.0 cfc2401896e1 2 years ago 126MB
goharbor/harbor-log v2.8.0 f31ccc3d46f0 2 years ago 134MB
goharbor/harbor-jobservice v2.8.0 1b00a3a474e1 2 years ago 140MB
goharbor/harbor-core v2.8.0 15f4066c1707 2 years ago 164MB
goharbor/harbor-portal v2.8.0 ae18a071cdce 2 years ago 133MB
goharbor/harbor-db v2.8.0 f3d4373617a2 2 years ago 179MB
goharbor/prepare v2.8.0 daa44ccf3b06 2 years ago 170MB
192.168.114.88/k8s/nginx latest 605c77e624dd 3 years ago 141MB
[root@localhost images]#:
本篇介绍Harbor的概念,docker与Harbor的安装使用,推送与拉取。下一篇介绍生产环境中Harbor端口号与密码的修改。
---end---