Docker Private Registry 常用组件
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.Docker Registry概述
1>.什么是registry
Registry用于保存docker镜像,包括镜像的层次结构和元数据。 用户可自建Registry,也可使用官方的Docker Hub。
2>.docker registry 分类
Sponsor Registry:
第三方的registry,供客户和Docker社区使用。 Mirror Registry:
第三方的registry,只让客户使用。 Vendor Registry:
由发布Docker镜像的供应商提供的registry。 Private Registry:
通过设有防火墙和额外的安全层的私有实体提供的registry。
二.使用docker官方提供的安装包(docker-registry)快速构建registry仓库
博主推荐阅读:Docker 官方手册(完整的可用参数列表):
https://docs.docker.com/engine/reference/commandline/dockerd/#run-multiple-daemons
1>.查看docker-registry软件包信息
[root@node102.yinzhengjie.org.cn ~]# yum info docker-registry #查看官方提供的软件包相关信息
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Available Packages
Name : docker-registry
Arch : x86_64
Version : 0.9.
Release : .el7
Size : k
Repo : extras//x86_64
Summary : Registry server for Docker
URL : https://github.com/docker/docker-registry
License : ASL 2.0
Description : Registry server for Docker (hosting/delivering of repositories and images). [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# yum info docker-registry #查看官方提供的软件包相关信息
2>.安装"docker-registry"软件
[root@node102.yinzhengjie.org.cn ~]# yum -y install docker-registry #安装该软件实际上会安装一个叫"docker-distribution"的软件
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
base | 3.6 kB ::
docker-ce-stable | 3.5 kB ::
extras | 2.9 kB ::
updates | 2.9 kB ::
(/): updates//x86_64/primary_db | 2.8 MB ::
(/): docker-ce-stable/x86_64/primary_db | kB ::
Package docker-registry is obsoleted by docker-distribution, trying to install docker-distribution-2.6.-.git48294d9.el7.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package docker-distribution.x86_64 :2.6.-.git48294d9.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
docker-distribution x86_64 2.6.-.git48294d9.el7 extras 3.5 M Transaction Summary
=================================================================================================================================================
Install Package Total download size: 3.5 M
Installed size: M
Downloading packages:
docker-distribution-2.6.-.git48294d9.el7.x86_64.rpm | 3.5 MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-distribution-2.6.-.git48294d9.el7.x86_64 /
Verifying : docker-distribution-2.6.-.git48294d9.el7.x86_64 / Installed:
docker-distribution.x86_64 :2.6.-.git48294d9.el7 Complete!
[root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# yum -y install docker-registry #安装该软件实际上会安装一个叫"docker-distribution"的软件
3>.查看"docker-distribution"软件包安装信息
[root@node102.yinzhengjie.org.cn ~]# rpm -ql docker-distribution
/etc/docker-distribution/registry/config.yml #该文件为配置文件
/usr/bin/registry
/usr/lib/systemd/system/docker-distribution.service
/usr/share/doc/docker-distribution-2.6.
/usr/share/doc/docker-distribution-2.6./AUTHORS
/usr/share/doc/docker-distribution-2.6./CONTRIBUTING.md
/usr/share/doc/docker-distribution-2.6./LICENSE
/usr/share/doc/docker-distribution-2.6./MAINTAINERS
/usr/share/doc/docker-distribution-2.6./README.md
/var/lib/registry #默认的镜像存储路径,建议生产环境使用一个较大的目录,可通过上面的配置文件进行修改。
[root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# rpm -ql docker-distribution
4>.启动"docker-distribution"服务
[root@node102.yinzhengjie.org.cn ~]# systemctl start docker-distribution
[root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN ::: :::*
LISTEN ::: :::*
[root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ll /var/lib/registry/ #由于我们还没有上传任何镜像,因此默认该目录是空的
total
[root@node102.yinzhengjie.org.cn ~]#
5>.客户端上传镜像到自建的registry仓库
[root@node101.yinzhengjie.org.cn ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test v0.- d2003d6841b7 hours ago .1MB
myweb v0.- c0a33ce27a6b hours ago 16MB
myweb v0.- fb0ef0b3aea3 hours ago 16MB
myweb v0.- 6f9999d46b69 hours ago 16MB
myweb v0.- 0110cfd06ce1 hours ago 16MB
myweb v0.- cb08b09cd959 hours ago 16MB
myweb v0.- 0082820cf7f0 hours ago 16MB
myweb v0.- fb4f5a5ac1ba hours ago 16MB
myweb v0.- 7697fbbe8233 hours ago 16MB
myweb v0.- b512ab335e80 hours ago 16MB
myweb v0.- 6162cd671ca9 hours ago 16MB
myweb v0.- f14829ada08d hours ago 16MB
tinyhttpd v0.- c06eb08ea6d6 hours ago .22MB
tinyhttpd v0.- c7447ee49e2b hours ago .22MB
tinyhttpd v0.- hours ago .22MB
tinyhttpd v0.- 24c887b252ad days ago .49MB
tinyhttpd v0.- 42c71beb05d5 days ago .45MB
tinyhttpd v0.- 9a5668f5f3a3 days ago .45MB
tinyhttpd v0.- 2368b7546664 days ago .45MB
tinyhttpd v0.- f6f58ddb1520 days ago .45MB
tinyhttpd v0.- 5086cc9cdc4a days ago .45MB
tinyhttpd v0.- aa780396b2a3 days ago .27MB
tinyhttpd v0.- de390df4c4c3 days ago .23MB
tinyhttpd v0.- 794f641ae85e days ago .22MB
redis latest de25a81a5a0b days ago .2MB
busybox latest 19485c79a9bb weeks ago .22MB
nginx 1.14-alpine 8a2fb25a19f5 months ago 16MB
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.- node102.yinzhengjie.org.cn:/myweb:v0.- #为客户端已有镜像打tag,便于上传到自建仓库
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test v0.- d2003d6841b7 hours ago .1MB
myweb v0.- c0a33ce27a6b hours ago 16MB
node102.yinzhengjie.org.cn:/myweb v0.- c0a33ce27a6b hours ago 16MB
myweb v0.- fb0ef0b3aea3 hours ago 16MB
myweb v0.- 6f9999d46b69 hours ago 16MB
myweb v0.- 0110cfd06ce1 hours ago 16MB
myweb v0.- cb08b09cd959 hours ago 16MB
myweb v0.- 0082820cf7f0 hours ago 16MB
myweb v0.- fb4f5a5ac1ba hours ago 16MB
myweb v0.- 7697fbbe8233 hours ago 16MB
myweb v0.- b512ab335e80 hours ago 16MB
myweb v0.- 6162cd671ca9 hours ago 16MB
myweb v0.- f14829ada08d hours ago 16MB
tinyhttpd v0.- c06eb08ea6d6 hours ago .22MB
tinyhttpd v0.- c7447ee49e2b hours ago .22MB
tinyhttpd v0.- hours ago .22MB
tinyhttpd v0.- 24c887b252ad days ago .49MB
tinyhttpd v0.- 42c71beb05d5 days ago .45MB
tinyhttpd v0.- 9a5668f5f3a3 days ago .45MB
tinyhttpd v0.- 2368b7546664 days ago .45MB
tinyhttpd v0.- f6f58ddb1520 days ago .45MB
tinyhttpd v0.- 5086cc9cdc4a days ago .45MB
tinyhttpd v0.- aa780396b2a3 days ago .27MB
tinyhttpd v0.- de390df4c4c3 days ago .23MB
tinyhttpd v0.- 794f641ae85e days ago .22MB
redis latest de25a81a5a0b days ago .2MB
busybox latest 19485c79a9bb weeks ago .22MB
nginx 1.14-alpine 8a2fb25a19f5 months ago 16MB
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.3-11 node102.yinzhengjie.org.cn:5000/myweb:v0.3-11 #为客户端已有镜像打tag,便于上传到自建仓库
[root@node101.yinzhengjie.org.cn ~]# docker push node102.yinzhengjie.org.cn:/myweb:v0.- #将已经打tag的镜像上传到自建仓库中失败,原因是默认使用HTTPS协议,而我们使用的是HTTP协议。
The push refers to repository [node102.yinzhengjie.org.cn:/myweb]
Get https://node102.yinzhengjie.org.cn:5000/v2/: http: server gave HTTP response to HTTPS client
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# vi /etc/docker/daemon.json
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/docker/daemon.json #我们在客户端配置"insecure-registries"参数。让该节点允许基于HTTP协议进行上传。
{
"registry-mirrors": ["https://tuv7rqqq.mirror.aliyuncs.com"],
"bip":"192.168.100.254/24",
"dns":["219.141.139.10","219.141.140.10"],
"hosts":["tcp://0.0.0.0:8888","unix:///var/run/docker.sock"],
"insecure-registries":["node102.yinzhengjie.org.cn:5000"]
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# systemctl restart docker
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker push node102.yinzhengjie.org.cn:/myweb:v0.- #将自定义镜像上传到自建的私有Registry中。
The push refers to repository [node102.yinzhengjie.org.cn:/myweb]
a7487ac35bc0: Pushed
edfefde38548: Pushed
076c58d2644f: Pushed
b2cbae4b8c15: Pushed
5ac9a5170bf2: Pushed
a464c54f93a9: Pushed
v0.-: digest: sha256:aafa903875c7f59f3f3f615097d292994ac5581a404bfe2f3cb77bf9389a9855 size:
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker push node102.yinzhengjie.org.cn:5000/myweb:v0.3-11 #将自定义镜像上传到自建的私有Registry中。
6>.查看服务端的镜像存储目录,发现的确由新目录生成
[root@node102.yinzhengjie.org.cn ~]# ll /var/lib/registry
total
drwxr-xr-x root root Oct : docker
[root@node102.yinzhengjie.org.cn ~]#
7>.使用客户端从自建的镜像仓库拉取镜像
[root@node103.yinzhengjie.org.cn ~]# docker images #当前节点本地还未有镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# docker pull node102.yinzhengjie.org.cn:/myweb:v0.- #下载私有仓库镜像失败,原因相比大家也知道了,继续参考上面的解决办法。
Error response from daemon: Get https://node102.yinzhengjie.org.cn:5000/v2/: http: server gave HTTP response to HTTPS client
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# vi /etc/docker/daemon.json
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# cat /etc/docker/daemon.json #我们可以理解"insecure-registries"将node102.yinzhengjie.org.cn:5000这个节点关闭安全检查
{
"registry-mirrors": ["https://tuv7rqqq.mirror.aliyuncs.com"],
"insecure-registries":["node102.yinzhengjie.org.cn:5000"]
}
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# systemctl restart docker
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# docker pull node102.yinzhengjie.org.cn:/myweb:v0.- #下载自建私有仓库的镜像到本地
v0.-: Pulling from myweb
bdf0201b3a05: Pull complete
3d0a573c81ed: Pull complete
8129faeb2eb6: Pull complete
3dc99f571daf: Pull complete
41addc55f022: Pull complete
ea60c368e85c: Pull complete
Digest: sha256:aafa903875c7f59f3f3f615097d292994ac5581a404bfe2f3cb77bf9389a9855
Status: Downloaded newer image for node102.yinzhengjie.org.cn:/myweb:v0.-
node102.yinzhengjie.org.cn:/myweb:v0.-
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
node102.yinzhengjie.org.cn:/myweb v0.- c0a33ce27a6b hours ago 16MB
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node102.yinzhengjie.org.cn:/myweb v0.- c0a33ce27a6b hours ago 16MB
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# docker pull node102.yinzhengjie.org.cn:5000/myweb:v0.3-11 #下载自建私有仓库的镜像到本地
三.Harbor私有仓库
1>.什么是Harbor
Project Harbor是一个开源的云原生registry项目,它支持存储、签名和扫描(判定镜像是否有安全风险)内容; Harbor通过添加用户通常需要的功能(如安全、身份和管理)扩展了开源Docker发行版; Harbor支持高级功能,如用户管理、访问控制、活动监视和实例之间的复制。 官方地址:https://goharbor.io
2>.Harbor特性
Multi-tenant content signing and validation(支持多租户内容签名和验证); Security and vulnerability analysis(支持安全及风险分析); Audit logging(支持审计日志); Identity integration and role-based access contron(支持身份整合与基于角色的访问控制); Image replication between instances(支持实例之间的映像复制); Extensible API and graphical UI(支持可扩展API和图形UI); Internationalization(currently English and Chinese,支持国际化,目前仅支持英文和中文)。
3>.Harbor安装指南
在物理机上Harbor的安装和部署是相当困难的,因此为了简化Harbor的应用,Harbor官方直接将Harbor做成了直接在容器中运行的应用; 由于Harbor容器依赖于redis,MySQL/PgSQL等很多存储系统,所以需要编排多个容器来协同工作,因此Vmware Harbor在部署和使用时需要借助于docker的单机编排工具,即Docker Compose(compose是一个定义和运行多容器docker的工具,官方地址:https://docs.docker.com/compose/)。
Harbor的GitHub地址:https://github.com/goharbor/harbor Harhor的安装指南:https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
[root@node103.yinzhengjie.org.cn ~]# yum info docker-compose #compose时一个定义和运行多容器docker的工具。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 8.0 kB ::
* base: mirrors.nju.edu.cn
* epel: hkg.mirror.rackspace.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.nju.edu.cn
epel | 5.3 kB ::
(/): epel/x86_64/group_gz | kB ::
(/): epel/x86_64/updateinfo | 1.0 MB ::
(/): epel/x86_64/primary_db | 6.9 MB ::
Available Packages
Name : docker-compose
Arch : noarch
Version : 1.18.
Release : .el7
Size : k
Repo : epel/x86_64
Summary : Multi-container orchestration for Docker
URL : https://github.com/docker/compose
License : ASL 2.0
Description : Compose is a tool for defining and running multi-container Docker
: applications. With Compose, you use a Compose file to configure your
: application's services. Then, using a single command, you create and
: start all the services from your configuration.
:
: Compose is great for development, testing, and staging environments,
: as well as CI workflows.
:
: Using Compose is basically a three-step process.
:
: . Define your app's environment with a Dockerfile so it can be
: reproduced anywhere.
: . Define the services that make up your app in docker-compose.yml so
: they can be run together in an isolated environment:
: . Lastly, run docker-compose up and Compose will start and run your
: entire app. [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# yum info docker-compose #compose时一个定义和运行多容器docker的工具。
4>.下载Harbor软件包(https://github.com/goharbor/harbor/releases)
[root@node103.yinzhengjie.org.cn ~]# wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.1.tgz
---- ::-- https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.1.tgz
Resolving storage.googleapis.com (storage.googleapis.com)... 172.217.160.80, ::::
Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.160.80|:... connected.
HTTP request sent, awaiting response... OK
Length: (590M) [application/x-tar]
Saving to: ‘harbor-offline-installer-v1.9.1.tgz’ %[=======================================================================================================>] ,, .49MB/s in 70s -- :: (8.44 MB/s) - ‘harbor-offline-installer-v1.9.1.tgz’ saved [/] [root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.1.tgz
5>.安装Harbor软件
[root@node103.yinzhengjie.org.cn ~]# ll
total
-rw-r--r-- root root Oct : harbor-offline-installer-v1.9.1.tgz
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# tar -xf harbor-offline-installer-v1.9.1.tgz -C /usr/local/
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# cd /usr/local/harbor/
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# ll
total
-rw-r--r-- root root Sep : harbor.v1.9.1.tar.gz
-rw-r--r-- root root Sep : harbor.yml #配置文件
-rwxr-xr-x root root Sep : install.sh #安装脚本
-rw-r--r-- root root Sep : LICENSE
-rwxr-xr-x root root Sep : prepare
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# grep hostname harbor.yml | grep -v ^# #此处我们可以修改一下主机名,打开该配置文件里面有相应的英文注释
hostname: node103.yinzhengjie.org.cn
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn ~]# yum -y install docker-compose #由于docker-compose是由python 3开发的,因此在安装该软件时我们会发现它会自动安装一些python模块。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.nju.edu.cn
* epel: hkg.mirror.rackspace.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.nju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package docker-compose.noarch :1.18.-.el7 will be installed
--> Processing Dependency: python(abi) = 3.6 for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-cached_property >= 1.2. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-docker >= 2.6. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-dockerpty >= 0.4. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-docopt >= 0.6. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-jsonschema >= 2.5. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-pysocks >= 1.5. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-requests >= 2.6. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-six >= 1.3. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-texttable >= 0.9. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-websocket-client >= 0.32. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-yaml >= 3.10 for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: /usr/bin/python3. for package: docker-compose-1.18.-.el7.noarch
--> Processing Dependency: python36-setuptools for package: docker-compose-1.18.-.el7.noarch
--> Running transaction check
---> Package python3.x86_64 :3.6.-.el7 will be installed
--> Processing Dependency: python3-libs(x86-) = 3.6.-.el7 for package: python3-3.6.-.el7.x86_64
--> Processing Dependency: python3-pip for package: python3-3.6.-.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.-.el7.x86_64
---> Package python3-setuptools.noarch :39.2.-.el7 will be installed
---> Package python36-PyYAML.x86_64 :3.12-.el7 will be installed
--> Processing Dependency: libyaml-.so.()(64bit) for package: python36-PyYAML-3.12-.el7.x86_64
---> Package python36-cached_property.noarch :1.5.-.el7 will be installed
---> Package python36-docker.noarch :2.6.-.el7 will be installed
--> Processing Dependency: python36-docker-pycreds >= 0.2. for package: python36-docker-2.6.-.el7.noarch
---> Package python36-dockerpty.noarch :0.4.-.el7 will be installed
---> Package python36-docopt.noarch :0.6.-.el7 will be installed
---> Package python36-jsonschema.noarch :2.5.-.el7 will be installed
---> Package python36-pysocks.noarch :1.6.-.el7 will be installed
---> Package python36-requests.noarch :2.12.-.el7 will be installed
--> Processing Dependency: python36-urllib3 = 1.19. for package: python36-requests-2.12.-.el7.noarch
--> Processing Dependency: python36-chardet for package: python36-requests-2.12.-.el7.noarch
--> Processing Dependency: python36-idna for package: python36-requests-2.12.-.el7.noarch
---> Package python36-six.noarch :1.11.-.el7 will be installed
---> Package python36-texttable.noarch :1.6.-.el7 will be installed
---> Package python36-websocket-client.noarch :0.47.-.el7 will be installed
--> Running transaction check
---> Package libyaml.x86_64 :0.1.-.el7_0 will be installed
---> Package python3-libs.x86_64 :3.6.-.el7 will be installed
--> Processing Dependency: libtirpc.so.()(64bit) for package: python3-libs-3.6.-.el7.x86_64
---> Package python3-pip.noarch :9.0.-.el7 will be installed
---> Package python36-chardet.noarch :3.0.-.el7 will be installed
---> Package python36-docker-pycreds.noarch :0.2.-.el7 will be installed
---> Package python36-idna.noarch :2.7-.el7 will be installed
---> Package python36-urllib3.noarch :1.19.-.el7 will be installed
--> Running transaction check
---> Package libtirpc.x86_64 :0.2.-0.16.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
docker-compose noarch 1.18.-.el7 epel k
Installing for dependencies:
libtirpc x86_64 0.2.-0.16.el7 base k
libyaml x86_64 0.1.-.el7_0 base k
python3 x86_64 3.6.-.el7 base k
python3-libs x86_64 3.6.-.el7 base 7.0 M
python3-pip noarch 9.0.-.el7 base 1.8 M
python3-setuptools noarch 39.2.-.el7 base k
python36-PyYAML x86_64 3.12-.el7 epel k
python36-cached_property noarch 1.5.-.el7 epel k
python36-chardet noarch 3.0.-.el7 epel k
python36-docker noarch 2.6.-.el7 epel k
python36-docker-pycreds noarch 0.2.-.el7 epel k
python36-dockerpty noarch 0.4.-.el7 epel k
python36-docopt noarch 0.6.-.el7 epel k
python36-idna noarch 2.7-.el7 epel k
python36-jsonschema noarch 2.5.-.el7 epel k
python36-pysocks noarch 1.6.-.el7 epel k
python36-requests noarch 2.12.-.el7 epel k
python36-six noarch 1.11.-.el7 epel k
python36-texttable noarch 1.6.-.el7 epel k
python36-urllib3 noarch 1.19.-.el7 epel k
python36-websocket-client noarch 0.47.-.el7 epel k Transaction Summary
=================================================================================================================================================
Install Package (+ Dependent packages) Total download size: M
Installed size: M
Downloading packages:
(/): libtirpc-0.2.-0.16.el7.x86_64.rpm | kB ::
(/): python3-libs-3.6.-.el7.x86_64.rpm | 7.0 MB ::
(/): python3-setuptools-39.2.-.el7.noarch.rpm | kB ::
(/): python3-pip-9.0.-.el7.noarch.rpm | 1.8 MB ::
(/): python36-PyYAML-3.12-.el7.x86_64.rpm | kB ::
(/): libyaml-0.1.-.el7_0.x86_64.rpm | kB ::
(/): docker-compose-1.18.-.el7.noarch.rpm | kB ::
(/): python36-chardet-3.0.-.el7.noarch.rpm | kB ::
(/): python36-docker-2.6.-.el7.noarch.rpm | kB ::
(/): python3-3.6.-.el7.x86_64.rpm | kB ::
(/): python36-cached_property-1.5.-.el7.noarch.rpm | kB ::
(/): python36-docker-pycreds-0.2.-.el7.noarch.rpm | kB ::
(/): python36-dockerpty-0.4.-.el7.noarch.rpm | kB ::
(/): python36-docopt-0.6.-.el7.noarch.rpm | kB ::
python36-idna-2.7-.el7.noarch FAILED
http://my.mirrors.thegigabit.com/epel/7/x86_64/Packages/p/python36-idna-2.7-2.el7.noarch.rpm: [Errno 12] Timeout on http://103.238.48.2/my.mirror
s.thegigabit.com/epel//x86_64/Packages/p/python36-idna-2.7-.el7.noarch.rpm: (, 'Connection timed out after 30997 milliseconds')Trying other mirror.
(/): python36-pysocks-1.6.-.el7.noarch.rpm | kB ::
(/): python36-requests-2.12.-.el7.noarch.rpm | kB ::
(/): python36-six-1.11.-.el7.noarch.rpm | kB ::
(/): python36-texttable-1.6.-.el7.noarch.rpm | kB ::
python36-jsonschema-2.5.-.el FAILED
http://my.mirrors.thegigabit.com/epel/7/x86_64/Packages/p/python36-jsonschema-2.5.1-4.el7.noarch.rpm: [Errno 12] Timeout on http://103.238.48.2/m
y.mirrors.thegigabit.com/epel//x86_64/Packages/p/python36-jsonschema-2.5.-.el7.noarch.rpm: (, 'Connection timed out after 30184 milliseconds')Trying other mirror.
(/): python36-urllib3-1.19.-.el7.noarch.rpm | kB ::
(/): python36-websocket-client-0.47.-.el7.noarch.rpm | kB ::
(/): python36-idna-2.7-.el7.noarch.rpm | kB ::
(/): python36-jsonschema-2.5.-.el7.noarch.rpm | kB ::
-------------------------------------------------------------------------------------------------------------------------------------------------
Total kB/s | MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libyaml-0.1.-.el7_0.x86_64 /
Installing : libtirpc-0.2.-0.16.el7.x86_64 /
Installing : python3-pip-9.0.-.el7.noarch /
Installing : python3-setuptools-39.2.-.el7.noarch /
Installing : python3-3.6.-.el7.x86_64 /
Installing : python3-libs-3.6.-.el7.x86_64 /
Installing : python36-six-1.11.-.el7.noarch /
Installing : python36-websocket-client-0.47.-.el7.noarch /
Installing : python36-pysocks-1.6.-.el7.noarch /
Installing : python36-urllib3-1.19.-.el7.noarch /
Installing : python36-dockerpty-0.4.-.el7.noarch /
Installing : python36-docker-pycreds-0.2.-.el7.noarch /
Installing : python36-PyYAML-3.12-.el7.x86_64 /
Installing : python36-texttable-1.6.-.el7.noarch /
Installing : python36-jsonschema-2.5.-.el7.noarch /
Installing : python36-idna-2.7-.el7.noarch /
Installing : python36-docopt-0.6.-.el7.noarch /
Installing : python36-cached_property-1.5.-.el7.noarch /
Installing : python36-chardet-3.0.-.el7.noarch /
Installing : python36-requests-2.12.-.el7.noarch /
Installing : python36-docker-2.6.-.el7.noarch /
Installing : docker-compose-1.18.-.el7.noarch /
Verifying : libtirpc-0.2.-0.16.el7.x86_64 /
Verifying : python36-pysocks-1.6.-.el7.noarch /
Verifying : python3-libs-3.6.-.el7.x86_64 /
Verifying : docker-compose-1.18.-.el7.noarch /
Verifying : python36-urllib3-1.19.-.el7.noarch /
Verifying : python3-pip-9.0.-.el7.noarch /
Verifying : python36-texttable-1.6.-.el7.noarch /
Verifying : python36-jsonschema-2.5.-.el7.noarch /
Verifying : python36-idna-2.7-.el7.noarch /
Verifying : python36-websocket-client-0.47.-.el7.noarch /
Verifying : python36-PyYAML-3.12-.el7.x86_64 /
Verifying : python36-dockerpty-0.4.-.el7.noarch /
Verifying : python36-docker-2.6.-.el7.noarch /
Verifying : python36-six-1.11.-.el7.noarch /
Verifying : python3-setuptools-39.2.-.el7.noarch /
Verifying : python36-docopt-0.6.-.el7.noarch /
Verifying : python36-cached_property-1.5.-.el7.noarch /
Verifying : python3-3.6.-.el7.x86_64 /
Verifying : libyaml-0.1.-.el7_0.x86_64 /
Verifying : python36-chardet-3.0.-.el7.noarch /
Verifying : python36-docker-pycreds-0.2.-.el7.noarch /
Verifying : python36-requests-2.12.-.el7.noarch / Installed:
docker-compose.noarch :1.18.-.el7 Dependency Installed:
libtirpc.x86_64 :0.2.-0.16.el7 libyaml.x86_64 :0.1.-.el7_0 python3.x86_64 :3.6.-.el7
python3-libs.x86_64 :3.6.-.el7 python3-pip.noarch :9.0.-.el7 python3-setuptools.noarch :39.2.-.el7
python36-PyYAML.x86_64 :3.12-.el7 python36-cached_property.noarch :1.5.-.el7 python36-chardet.noarch :3.0.-.el7
python36-docker.noarch :2.6.-.el7 python36-docker-pycreds.noarch :0.2.-.el7 python36-dockerpty.noarch :0.4.-.el7
python36-docopt.noarch :0.6.-.el7 python36-idna.noarch :2.7-.el7 python36-jsonschema.noarch :2.5.-.el7
python36-pysocks.noarch :1.6.-.el7 python36-requests.noarch :2.12.-.el7 python36-six.noarch :1.11.-.el7
python36-texttable.noarch :1.6.-.el7 python36-urllib3.noarch :1.19.-.el7 python36-websocket-client.noarch :0.47.-.el7 Complete!
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# yum -y install docker-compose #由于docker-compose是由python 3开发的,因此在安装该软件时我们会发现它会自动安装一些python模块。
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# ll
total
-rw-r--r-- root root Sep : harbor.v1.9.1.tar.gz
-rw-r--r-- root root Oct : harbor.yml
-rwxr-xr-x root root Sep : install.sh
-rw-r--r-- root root Sep : LICENSE
-rwxr-xr-x root root Sep : prepare
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# ./install.sh #安装Harbor软件,安装完成后它会自动启动相关web服务 [Step ]: checking installation environment ... Note: docker version: 19.03. Note: docker-compose version: 1.18. [Step ]: loading Harbor images ...
b80136ee24a4: Loading layer [==================================================>] .25MB/.25MB
cad87ea2da29: Loading layer [==================================================>] .02MB/.02MB
034ded39ed39: Loading layer [==================================================>] .072kB/.072kB
f6ca716ef169: Loading layer [==================================================>] .9kB/.9kB
baf21a4a14d3: Loading layer [==================================================>] .95kB/.95kB
Loaded image: goharbor/redis-photon:v1.9.1
38d0cc9d1ffd: Loading layer [==================================================>] .98MB/.98MB
f68a1f0c31fc: Loading layer [==================================================>] .072kB/.072kB
72515108750d: Loading layer [==================================================>] .56kB/.56kB
a2cda355c3ef: Loading layer [==================================================>] .1MB/.1MB
ab2865eb128e: Loading layer [==================================================>] .1MB/.1MB
Loaded image: goharbor/registry-photon:v2.7.1-patch---v1.9.1
527ef66806e1: Loading layer [==================================================>] .98MB/.98MB
0f11d90dd35b: Loading layer [==================================================>] .072kB/.072kB
3425f8898e4f: Loading layer [==================================================>] .1MB/.1MB
cfa38640b856: Loading layer [==================================================>] .072kB/.072kB
e7794afc289f: Loading layer [==================================================>] .661MB/.661MB
76012da7ad6a: Loading layer [==================================================>] .76MB/.76MB
Loaded image: goharbor/harbor-registryctl:v1.9.1
e83beb288a0d: Loading layer [==================================================>] 113MB/113MB
93e08bdb2f3c: Loading layer [==================================================>] .17MB/.17MB
7a823857fc40: Loading layer [==================================================>] .048kB/.048kB
fc24f20df72d: Loading layer [==================================================>] .13kB/.13kB
bd925688a6c6: Loading layer [==================================================>] .072kB/.072kB
d0812a8a6aa1: Loading layer [==================================================>] .22MB/.22MB
Loaded image: goharbor/clair-photon:v2.0.9-v1.9.1
4c42b997c1d3: Loading layer [==================================================>] .7MB/.7MB
b921c11a7cce: Loading layer [==================================================>] .8kB/.8kB
Loaded image: goharbor/harbor-migrator:v1.9.1
50d9ef917fd0: Loading layer [==================================================>] .985MB/.985MB
49be4811c210: Loading layer [==================================================>] .39MB/.39MB
e3e7d0ecbd56: Loading layer [==================================================>] .048kB/.048kB
bd6ae8ad3688: Loading layer [==================================================>] .072kB/.072kB
f8daafb6452b: Loading layer [==================================================>] .4MB/.4MB
Loaded image: goharbor/chartmuseum-photon:v0.9.0-v1.9.1
f8be5d65a497: Loading layer [==================================================>] .56kB/.56kB
ec2558a18995: Loading layer [==================================================>] .536kB/.536kB
9253b305f3e0: Loading layer [==================================================>] .14MB/.14MB
f5bc3b95773b: Loading layer [==================================================>] .56MB/.56MB
1cb18728da6a: Loading layer [==================================================>] .7kB/.7kB
10d8c3845ea7: Loading layer [==================================================>] .006MB/.006MB
Loaded image: goharbor/prepare:v1.9.1
63f870b51f41: Loading layer [==================================================>] .49MB/.49MB
7306099794e1: Loading layer [==================================================>] .21MB/.21MB
8a9f36b3fb5f: Loading layer [==================================================>] .632kB/.632kB
75daaad9bfa8: Loading layer [==================================================>] .048kB/.048kB
d8f94d1114c6: Loading layer [==================================================>] .56kB/.56kB
7ecefe35a143: Loading layer [==================================================>] .56kB/.56kB
a8fab8d5af16: Loading layer [==================================================>] .56kB/.56kB
94cf351a3c19: Loading layer [==================================================>] .24kB/.24kB
Loaded image: goharbor/harbor-db:v1.9.1
9837bf8ee24e: Loading layer [==================================================>] .979MB/.979MB
ba364bbbdbdd: Loading layer [==================================================>] .239MB/.239MB
3fd94bb9f201: Loading layer [==================================================>] .13MB/.13MB
a71f5b58dc99: Loading layer [==================================================>] .47MB/.47MB
80997da865e8: Loading layer [==================================================>] .02kB/.02kB
376d829dd4a8: Loading layer [==================================================>] .84MB/.84MB
Loaded image: goharbor/notary-server-photon:v0.6.1-v1.9.1
7310144c80b8: Loading layer [==================================================>] .75MB/.75MB
57822721a26e: Loading layer [==================================================>] .13MB/.13MB
Loaded image: goharbor/harbor-jobservice:v1.9.1
b9172b8bd1c0: Loading layer [==================================================>] .82MB/.82MB
Loaded image: goharbor/nginx-photon:v1.9.1
3999c34ab3d1: Loading layer [==================================================>] .72MB/.72MB
55d2a47566d6: Loading layer [==================================================>] .47MB/.47MB
605a3b90e10b: Loading layer [==================================================>] .02kB/.02kB
753afe3849f7: Loading layer [==================================================>] .43MB/.43MB
Loaded image: goharbor/notary-signer-photon:v0.6.1-v1.9.1
f6d400c78205: Loading layer [==================================================>] .012MB/.012MB
da6e265c346e: Loading layer [==================================================>] .6kB/.6kB
11f6a9c90cd1: Loading layer [==================================================>] 172kB/172kB
99996a16f7b1: Loading layer [==================================================>] .36kB/.36kB
d94e53aaf9b8: Loading layer [==================================================>] .584kB/.584kB
b84ee50e8238: Loading layer [==================================================>] .82MB/.82MB
Loaded image: goharbor/harbor-portal:v1.9.1
e755a945ae2a: Loading layer [==================================================>] .75MB/.75MB
dc5d22c53956: Loading layer [==================================================>] .39MB/.39MB
15f93df7269e: Loading layer [==================================================>] .632kB/.632kB
ee595495168a: Loading layer [==================================================>] .35kB/.35kB
8fb7538d9d82: Loading layer [==================================================>] .39MB/.39MB
Loaded image: goharbor/harbor-core:v1.9.1
3e458fabaeef: Loading layer [==================================================>] .61MB/.61MB
2a88a9994014: Loading layer [==================================================>] .584kB/.584kB
19d8eee966bd: Loading layer [==================================================>] .072kB/.072kB
bd017a9bef7c: Loading layer [==================================================>] .56kB/.56kB
186ca97fbd0d: Loading layer [==================================================>] .072kB/.072kB
8b15fc511dbf: Loading layer [==================================================>] .584kB/.584kB
cc84783073de: Loading layer [==================================================>] .29kB/.29kB
Loaded image: goharbor/harbor-log:v1.9.1 [Step ]: preparing environment ...
prepare base dir is set to /usr/local/harbor
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
Generated and saved secret to file: /secret/keys/secretkey
Creating harbor-log ... done
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir Creating registry ... done
Creating harbor-core ... done
Creating network "harbor_harbor" with the default driver
Creating nginx ... done
Creating harbor-db ...
Creating registry ...
Creating redis ...
Creating harbor-portal ...
Creating registryctl ...
Creating harbor-core ...
Creating nginx ...
Creating harbor-jobservice ... ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://node103.yinzhengjie.org.cn.
For more details, please visit https://github.com/goharbor/harbor . [root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# echo $? [root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# ll
total
drwxr-xr-x root root Oct : common
-rw-r--r-- root root Oct : docker-compose.yml
-rw-r--r-- root root Sep : harbor.v1.9.1.tar.gz
-rw-r--r-- root root Oct : harbor.yml
-rwxr-xr-x root root Sep : install.sh
-rw-r--r-- root root Sep : LICENSE
-rwxr-xr-x root root Sep : prepare
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# ./install.sh #安装Harbor软件,安装完成后它会自动启动相关web服务
6>.访问Harbor的Web UI
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 127.0.0.1: 0.0.0.0:* LISTEN
tcp 0.0.0.0: 0.0.0.0:* LISTEN
tcp6 ::: :::* LISTEN
tcp6 ::: :::* LISTEN
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# grep harbor_admin_password harbor.yml #这是Harbor服务的默认密码,如果有需要可以在安装服务前自行修改哟~
harbor_admin_password: Harbor12345
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
7>.Harbor的Web UI登录成功
四.基于自建Harbor上传镜像案例演示(日志存放路径: "/var/log/harbor")
1>.使用普通用户登录
2>.登录成功
3>.点击"新建项目",自定义项目名称
4>.进入新创建的项目
5>.查看推送镜像的方式
6>.将"node101.yinzhengjie.org.cn"节点的自建镜像推送到"node103.yinzhengjie.org.cn"的Harbor仓库
[root@node101.yinzhengjie.org.cn ~]# cat /etc/docker/daemon.json #关闭node103.yinzhengjie.org.cn的安全检查并重启服务
{
"registry-mirrors": ["https://tuv7rqqq.mirror.aliyuncs.com"],
"bip":"192.168.100.254/24",
"dns":["219.141.139.10","219.141.140.10"],
"hosts":["tcp://0.0.0.0:8888","unix:///var/run/docker.sock"],
"insecure-registries":["node102.yinzhengjie.org.cn:5000"],
"insecure-registries":["node103.yinzhengjie.org.cn:80"]
}
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# systemctl restart docker
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/docker/daemon.json #关闭node103.yinzhengjie.org.cn的安全检查并重启服务
[root@node101.yinzhengjie.org.cn ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test v0.- d2003d6841b7 hours ago .1MB
myweb v0.- c0a33ce27a6b hours ago 16MB
node102.yinzhengjie.org.cn:/myweb v0.- c0a33ce27a6b hours ago 16MB
myweb v0.- fb0ef0b3aea3 hours ago 16MB
myweb v0.- 6f9999d46b69 hours ago 16MB
myweb v0.- 0110cfd06ce1 hours ago 16MB
myweb v0.- cb08b09cd959 hours ago 16MB
myweb v0.- 0082820cf7f0 hours ago 16MB
myweb v0.- fb4f5a5ac1ba hours ago 16MB
myweb v0.- 7697fbbe8233 hours ago 16MB
myweb v0.- b512ab335e80 hours ago 16MB
myweb v0.- 6162cd671ca9 hours ago 16MB
myweb v0.- f14829ada08d hours ago 16MB
tinyhttpd v0.- c06eb08ea6d6 hours ago .22MB
tinyhttpd v0.- c7447ee49e2b days ago .22MB
tinyhttpd v0.- days ago .22MB
tinyhttpd v0.- 24c887b252ad days ago .49MB
tinyhttpd v0.- 42c71beb05d5 days ago .45MB
tinyhttpd v0.- 9a5668f5f3a3 days ago .45MB
tinyhttpd v0.- 2368b7546664 days ago .45MB
tinyhttpd v0.- f6f58ddb1520 days ago .45MB
tinyhttpd v0.- 5086cc9cdc4a days ago .45MB
tinyhttpd v0.- aa780396b2a3 days ago .27MB
tinyhttpd v0.- de390df4c4c3 days ago .23MB
tinyhttpd v0.- 794f641ae85e days ago .22MB
redis latest de25a81a5a0b days ago .2MB
busybox latest 19485c79a9bb weeks ago .22MB
nginx 1.14-alpine 8a2fb25a19f5 months ago 16MB
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.- node103.yinzhengjie.org.cn:/devops/myweb:v0.- #将已经有的镜像进行打tag操作(咱们为了试验效果,共tag了5个镜像)
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.- node103.yinzhengjie.org.cn:/devops/myweb:v0.-
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.- node103.yinzhengjie.org.cn:/devops/myweb:v0.-
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.- node103.yinzhengjie.org.cn:/devops/myweb:v0.-
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.- node103.yinzhengjie.org.cn:/devops/myweb:v0.-
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test v0.- d2003d6841b7 hours ago .1MB
myweb v0.- c0a33ce27a6b hours ago 16MB
node102.yinzhengjie.org.cn:/myweb v0.- c0a33ce27a6b hours ago 16MB
myweb v0.- fb0ef0b3aea3 hours ago 16MB
myweb v0.- 6f9999d46b69 hours ago 16MB
myweb v0.- 0110cfd06ce1 hours ago 16MB
myweb v0.- cb08b09cd959 hours ago 16MB
myweb v0.- 0082820cf7f0 hours ago 16MB
myweb v0.- fb4f5a5ac1ba hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- fb4f5a5ac1ba hours ago 16MB
myweb v0.- 7697fbbe8233 hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- 7697fbbe8233 hours ago 16MB
myweb v0.- b512ab335e80 hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- b512ab335e80 hours ago 16MB
myweb v0.- 6162cd671ca9 hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- 6162cd671ca9 hours ago 16MB
myweb v0.- f14829ada08d hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- f14829ada08d hours ago 16MB
tinyhttpd v0.- c06eb08ea6d6 hours ago .22MB
tinyhttpd v0.- c7447ee49e2b days ago .22MB
tinyhttpd v0.- days ago .22MB
tinyhttpd v0.- 24c887b252ad days ago .49MB
tinyhttpd v0.- 42c71beb05d5 days ago .45MB
tinyhttpd v0.- 9a5668f5f3a3 days ago .45MB
tinyhttpd v0.- 2368b7546664 days ago .45MB
tinyhttpd v0.- f6f58ddb1520 days ago .45MB
tinyhttpd v0.- 5086cc9cdc4a days ago .45MB
tinyhttpd v0.- aa780396b2a3 days ago .27MB
tinyhttpd v0.- de390df4c4c3 days ago .23MB
tinyhttpd v0.- 794f641ae85e days ago .22MB
redis latest de25a81a5a0b days ago .2MB
busybox latest 19485c79a9bb weeks ago .22MB
nginx 1.14-alpine 8a2fb25a19f5 months ago 16MB
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker tag myweb:v0.3-1 node103.yinzhengjie.org.cn:80/devops/myweb:v0.3-1 #将已经有的镜像进行打tag操作(咱们为了试验效果,共tag了5个镜像)
[root@node101.yinzhengjie.org.cn ~]# docker login node103.yinzhengjie.org.cn: #此处我们基于80端口登录,默认时基于443端口登录的
Username: yinzhengjie
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@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker login node103.yinzhengjie.org.cn:80 #此处我们基于80端口登录,默认时基于443端口登录的
[root@node101.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
test v0.- d2003d6841b7 hours ago .1MB
node102.yinzhengjie.org.cn:/myweb v0.- c0a33ce27a6b hours ago 16MB
myweb v0.- c0a33ce27a6b hours ago 16MB
myweb v0.- fb0ef0b3aea3 hours ago 16MB
myweb v0.- 6f9999d46b69 hours ago 16MB
myweb v0.- 0110cfd06ce1 hours ago 16MB
myweb v0.- cb08b09cd959 hours ago 16MB
myweb v0.- 0082820cf7f0 hours ago 16MB
myweb v0.- fb4f5a5ac1ba hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- fb4f5a5ac1ba hours ago 16MB
myweb v0.- 7697fbbe8233 hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- 7697fbbe8233 hours ago 16MB
myweb v0.- b512ab335e80 hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- b512ab335e80 hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- 6162cd671ca9 hours ago 16MB
myweb v0.- 6162cd671ca9 hours ago 16MB
myweb v0.- f14829ada08d hours ago 16MB
node103.yinzhengjie.org.cn:/devops/myweb v0.- f14829ada08d hours ago 16MB
tinyhttpd v0.- c06eb08ea6d6 hours ago .22MB
tinyhttpd v0.- c7447ee49e2b days ago .22MB
tinyhttpd v0.- days ago .22MB
tinyhttpd v0.- 24c887b252ad days ago .49MB
tinyhttpd v0.- 42c71beb05d5 days ago .45MB
tinyhttpd v0.- 9a5668f5f3a3 days ago .45MB
tinyhttpd v0.- 2368b7546664 days ago .45MB
tinyhttpd v0.- f6f58ddb1520 days ago .45MB
tinyhttpd v0.- 5086cc9cdc4a days ago .45MB
tinyhttpd v0.- aa780396b2a3 days ago .27MB
tinyhttpd v0.- de390df4c4c3 days ago .23MB
tinyhttpd v0.- 794f641ae85e days ago .22MB
redis latest de25a81a5a0b days ago .2MB
busybox latest 19485c79a9bb weeks ago .22MB
nginx 1.14-alpine 8a2fb25a19f5 months ago 16MB
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker push node103.yinzhengjie.org.cn:/devops/myweb #将已经打好tag的镜像全部推送到已经登录的Harbor服务器上
The push refers to repository [node103.yinzhengjie.org.cn:/devops/myweb]
55514dc3bafb: Pushed
076c58d2644f: Pushed
b2cbae4b8c15: Pushed
5ac9a5170bf2: Pushed
a464c54f93a9: Pushed
v0.-: digest: sha256:9c7535800e955be11ffa7ab5adb0d758b11ddee3c11ea408cc6eab7755890710 size:
55514dc3bafb: Layer already exists
076c58d2644f: Layer already exists
b2cbae4b8c15: Layer already exists
5ac9a5170bf2: Layer already exists
a464c54f93a9: Layer already exists
v0.-: digest: sha256:f79e1abd048ce9e4e5ee2ebfe4a1a3454772b14b0818fcf5fe117418e6038280 size:
55514dc3bafb: Layer already exists
076c58d2644f: Layer already exists
b2cbae4b8c15: Layer already exists
5ac9a5170bf2: Layer already exists
a464c54f93a9: Layer already exists
v0.-: digest: sha256:4ad45d226ea605f1625967a1cfe86fe22fff535becb722d20a2abd0b5ca88e97 size:
0dac9c03dd8a: Pushed
076c58d2644f: Layer already exists
b2cbae4b8c15: Layer already exists
5ac9a5170bf2: Layer already exists
a464c54f93a9: Layer already exists
v0.-: digest: sha256:894dea926a0d07248ddbd80ca83ce7149c0d4f9250933a681981f418fe0e98b2 size:
77040215254b: Pushed
076c58d2644f: Layer already exists
b2cbae4b8c15: Layer already exists
5ac9a5170bf2: Layer already exists
a464c54f93a9: Layer already exists
v0.-: digest: sha256:b436ff5ab1f8e626015a351588c74cad0a006ae99b62565f5aea6721050dec27 size:
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# docker push node103.yinzhengjie.org.cn:80/devops/myweb #将已经打好tag的镜像全部推送到已经登录的Harbor服务器上
7>.在Harbor的Web UI查看上传的镜像详细信息
8>.docker-compose脚本文件概述(建议熟悉Harbor服务的配置文件:"/usr/local/harbor/harbor.yml")
[root@node103.yinzhengjie.org.cn ~]# docker-compose --help #查看该命令的帮助信息
Define and run multi-container applications with Docker. Usage:
docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
docker-compose -h|--help Options:
-f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name (default: directory name)
--verbose Show more output
--no-ansi Do not print ANSI control characters
-v, --version Print version and exit
-H, --host HOST Daemon socket to connect to --tls Use TLS; implied by --tlsverify
--tlscacert CA_PATH Trust certs signed only by this CA
--tlscert CLIENT_CERT_PATH Path to TLS certificate file
--tlskey TLS_KEY_PATH Path to TLS key file
--tlsverify Use TLS and verify the remote
--skip-hostname-check Don't check the daemon's hostname against the name specified
in the client certificate (for example if your docker host
is an IP address)
--project-directory PATH Specify an alternate working directory
(default: the path of the Compose file) Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the Compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
images List images
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
[root@node103.yinzhengjie.org.cn ~]#
[root@node103.yinzhengjie.org.cn ~]# docker-compose --help #查看该命令的帮助信息
[root@node103.yinzhengjie.org.cn ~]# cd /usr/local/harbor/
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# ll
total
drwxr-xr-x root root Oct : common
-rw-r--r-- root root Oct : docker-compose.yml
-rw-r--r-- root root Sep : harbor.v1.9.1.tar.gz
-rw-r--r-- root root Oct : harbor.yml
-rwxr-xr-x root root Sep : install.sh
-rw-r--r-- root root Sep : LICENSE
-rwxr-xr-x root root Sep : prepare
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# docker-compose pause #执行暂停服务命令时要进入存放"harbor.yml"的目录
Pausing harbor-log ... done
Pausing harbor-db ... done
Pausing registry ... done
Pausing redis ... done
Pausing harbor-portal ... done
Pausing registryctl ... done
Pausing harbor-core ... done
Pausing harbor-jobservice ... done
Pausing nginx ... done
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# docker-compose pause #执行暂停服务命令时要进入存放"harbor.yml"的目录
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# docker-compose unpause #不暂停harbor服务
Unpausing nginx ... done
Unpausing harbor-jobservice ... done
Unpausing harbor-core ... done
Unpausing registryctl ... done
Unpausing harbor-portal ... done
Unpausing redis ... done
Unpausing registry ... done
Unpausing harbor-db ... done
Unpausing harbor-log ... done
[root@node103.yinzhengjie.org.cn /usr/local/harbor]#
[root@node103.yinzhengjie.org.cn /usr/local/harbor]# docker-compose unpause #不暂停harbor服务