网站域名和邮箱域名解析,国外网站国内做二维码,长垣建设银行网站,微信公众号商城怎么开通文章目录 Harbor安装完成harbor 官方建议方式之后查看 images配置docker 使用harbor 仓库上传下载镜像docker 镜像结合harbor 运行 Harbor Harbor 是一个用于存储和分发 Docker 镜像的企业级 Registry 服务器#xff0c;由
vmware 开源#xff0c;其通过添加一些企业必需的功… 文章目录 Harbor安装完成harbor 官方建议方式之后查看 images配置docker 使用harbor 仓库上传下载镜像docker 镜像结合harbor 运行 Harbor
Harbor 是一个用于存储和分发 Docker 镜像的企业级 Registry 服务器由
vmware 开源其通过添加一些企业必需的功能特性例如安全、标识和管理等
扩展了开源 Docker Distribution。作为一个企业级私有 Registry 服务器Harbor
提供了更好的性能和安全。提升用户使用 Registry 构建和运行环境传输镜像的
效率。Harbor 支持安装在多个 Registry 节点的镜像资源复制镜像全部保存在
私有 Registry 中 确保数据和知识产权在公司内部网络中管控另外Harbor
也提供了高级的安全特性诸如用户管理访问控制和活动审计等。误区一: Harbor是负责存储容器镜像的 (Harbor是镜像仓库那么它就应当是存储镜像的)
其实关于镜像的存储Harbor使用的是官方的docker registry服务去完成至于registry是用本地存储或者s3都是可以的Harbor的功能是在此之上提供用户权限管理、镜像复制等功能提高使用的registry的效率。误区二Harbor镜像复制是存储直接复制 (镜像的复制很多人以为应该是镜像分层文件的直接拷贝)
其实Harbor镜像复制采用了一个更加通用、高屋建瓴的做法通过docker registry 的API去拷贝这不是省事这种做法屏蔽了繁琐的底层文件操作、不仅可以利用现有docker registry功能不必重复造轮子而且可以解决冲突和一致性的问题。下载地址https://github.com/goharbor/harbor/releases
直接选择编译好的包cd /usr/local/src
wget https://github.com/goharbor/harbor/releases/download/v2.7.3/harbor-offline-installer-v2.7.3.tgz
解压
ln -sv /usr/local/src/harbor /usr/local/harbor安装docker-compose curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-composechmod x /usr/local/bin/docker-compose
docker-compose --versionharbor.yml 就是harbor的配置文件
harbor的数据目录为/data
编辑harbor.yml修改hostname、https证书路径、admin密码如果是http 则将https 全部注释了包括证书路径注意每次修改完配置文件后都需要运行
./prepare
然后在运行
./install.shharbor.yml 配置文件如下# 配置如下
hostname: harbor.test.com
port: 9010
harbor_admin_password: phpdev-pass
# The location to store harbors data
data_volume: /usr/src/harbor/data
# The directory to store store log
location: /var/log/harbor
安装完成harbor 官方建议方式之后查看 images
[rootlight-test ~[]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v1 35b319a48e3b 24 hours ago 669MB
tomcat latest e76527586e57 11 days ago 454MB
goharbor/harbor-exporter v2.7.3 44f17702b0d6 3 months ago 96.9MB
goharbor/chartmuseum-photon v2.7.3 e21f928bea75 3 months ago 229MB
goharbor/redis-photon v2.7.3 68ef52d98298 3 months ago 120MB
goharbor/trivy-adapter-photon v2.7.3 aabf279df9cc 3 months ago 463MB
goharbor/notary-server-photon v2.7.3 992cbac9892b 3 months ago 113MB
goharbor/notary-signer-photon v2.7.3 e384f965170c 3 months ago 110MB
goharbor/harbor-registryctl v2.7.3 0adcdbbc67c8 3 months ago 140MB
goharbor/registry-photon v2.7.3 91fa7c3c922c 3 months ago 78.7MB
goharbor/nginx-photon v2.7.3 a780e583d37f 3 months ago 116MB
goharbor/harbor-log v2.7.3 48a9ddf4a380 3 months ago 128MB
goharbor/harbor-jobservice v2.7.3 265eda6d72aa 3 months ago 260MB
goharbor/harbor-core v2.7.3 1a415c050c9c 3 months ago 222MB
goharbor/harbor-portal v2.7.3 9a0f808a9eed 3 months ago 125MB
goharbor/harbor-db v2.7.3 731c8c0fe6ca 3 months ago 174MB
goharbor/prepare v2.7.3 36fd5b190502 3 months ago 168MB
mysql latest 99afc808f15b 4 months ago 577MB
mysql 5.7 92034fe9a41f 4 months ago 581MB
jenkins/jenkins lts-jdk11 a40a8916af1d 4 months ago 471MB登录 注意启动的配置文件 harbor.yml 里面配置停止服务 docker-compose stop
开始服务 docker-compose start
重启服务docker-compose restart
停止服务并删除容器docker-compose down
启动服务并运行容器docker-compose up 配置docker 使用harbor 仓库上传下载镜像
注意如果我们配置的是 https 的话本地 docker 就不需要有任何操作就可以
访问 harbor如果是http 则需要编辑如下文件如下在/etc/docker/daemon.json文件里添加insecure-registries配置。如果还不行可以尝试将下面添加的地址由172.16.60.213改为http://172.16.60.213
[rootdocker-client ~]# vim /etc/docker/daemon.json
{insecure-registries: [38.50.0..0:8888]
}/etc/hosts 文件添加一个域名的解析[rootlight-test harbor[]# docker login 38.50.0..0:8888
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登录的账号密码 保存在这里了
cat /root/.docker/config.jsonharbor支持http和https但如果使用http的话在拉取镜像的时候会抛出仓库不受信任的异常。
需要在所有的docker客户端的docker配置文件/etc/docker/daemon.json中添加如下配置:{insecure-registries: [https://*.*.*.*]
}docker info 中查看 是不是配置好了harbor 地址查看 Insecure Registries: 选项参数docker 镜像结合harbor 运行
[rootlight-test ~[]# docker tag nginx:v1 38.0.0.3:8888/nginx/nginxv1
[rootlight-test ~[]# docker push 38.0.0.3:8888/nginx/nginxv1
Using default tag: latest
The push refers to repository [38.0.0.3:8888/nginx/nginxv1]
756b20a16ba8: Pushed
3c057e1b7942: Pushed
b17962786f9c: Pushed
072efff24baf: Pushed
51646e2b38b3: Pushed
7bf293509842: Pushed
fb82b029bea0: Pushed
latest: digest: sha256:4d414e6bd375797e730cb52712d3802e8b1be5cbaba7171e47745776a5e8af40 size: 1787
[rootlight-test ~[]# docker pull 38.0.0.3:8888/nginx/nginx
-bash: dockr: 未找到命令
[rootlight-test ~[]# docker pusll 38.0.0.3:8888/nginx/nginx
docker: pusll is not a docker command.
See docker --help
[rootlight-test ~[]# docker pull 38.0.0.3:8888/nginx/nginx
Using default tag: latest
latest: Pulling from nginx/nginx
Digest: sha256:4d414e6bd375797e730cb52712d3802e8b1be5cbaba7171e47745776a5e8af40
Status: Downloaded newer image for 38.0.0.3:8888/nginx/nginx:latest
38.0.0.3:8888/nginx/nginx:latest
[rootlight-test ~[]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
38.0.0.3:8888/nginx/nginx latest 35b319a48e3b 40 hours ago 669MB
38.0.0.3:8888/nginx/nginxv1 latest 35b319a48e3b 40 hours ago 669MB 参考文档 https://www.cnblogs.com/quqibinggan/p/16880549.html 马哥