docker 镜像仓库 Harbor 部署 跨数据复制
Harbor 是 Vmwar 公司开源的 企业级的 Docker Registry 管理项目
它主要 提供 Dcoker Registry 管理UI,可基于角色访问控制, AD/LDAP 集成,日志审核等功能,完全的支持中文。
Harbor 的所有组件都在 Dcoker 中部署,所以 Harbor 可使用 Docker Compose 快速部署。
Docker简介
Docker项目提供了构建在Linux内核功能之上,协同在一起的的高级工具。其目标是帮助开发和运维人员更容易地跨系统跨主机交付应用程序和他们的依赖。Docker通过Docker容器,一个安全的,基于轻量级容器的环境,来实现这个目标。这些容器由镜像创建,而镜像可以通过命令行手工创建或 者通过Dockerfile自动创建。
1.安装yun-utils,这样就能使用yun-config-manager工具设置Yum源。
$ sudo yum install -y yum-utils
如果出现以下信息:
已加载插件:fastestmirror, langpacks
/var/run/yum.pid 已被锁定,PID 为 3012 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:PackageKit
内存:135 M RSS (1.4 GB VSZ)
已启动: Sun Aug 19 10:35:25 2018 - 04:56之前
状态 :睡眠中,进程ID:3012
需要执行
$ rm -rf /var/run/yum.pid
$ sudo yum install -y yum yum-utils
2. 添加Docker的Yum源,使用官方的docker-ce.repo源进行安装docker-ce,由于国内访问该地址网络原因,会报下面错误。
[Errno 12] Timeout on https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml
可以参考上一篇文章:centos7 install docker-ce 报错:time out问题处理解决此问题。
3. 更新Yum索引
$ sudo yum makecache fast
4.可以查看所有仓库中所有docker版本,并选择特定版本安装
$ yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror, langpacks
可安装的软件包
* updates: centos.ustc.edu.cn
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
...
5.安装Docker,命令:yum install docker-ce-版本号,我选的是17.12.1.ce,如下
$ yum install docker-ce-17.12.1.ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
base | 3.6 kB 00:00
docker-ce-stable | 2.9 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.17.12.1.ce-1.el7.centos 将被 安装
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 docker-ce-17.12.1.ce-1.el7.centos.x86_64 需要
...
6.启动Docker,命令:systemctl start docker,然后加入开机启动,如下
$ systemctl start docker
$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
7.验证安装是否成功(有client和service两部分表示docker安装启动都成功了)
$ docker version
Client:
Version: 17.12.1-ce
API version: 1.35
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:15:20 2018
OS/Arch: linux/amd64
Server:
Engine:
Version: 17.12.1-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.4
Git commit: 7390fc6
Built: Tue Feb 27 22:17:54 2018
OS/Arch: linux/amd64
Experimental: false
国内访问Docker Hub的速度很不稳定,有时甚至连接不上,可以配置镜像加速器解决这个问题。国内很多云服务商提供镜像加速的服务,我们使用阿里云加速器https://cr.console.aliyun.com/cn-hangzhou/mirrors 。
执行以下命令:
$ sudo mkdir -p /etc/docker
#如果没有deamon.json文件,则新建此文件
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://pzadm966.mirror.aliyuncs.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
Docker容器常用命令
下面是Docker容器常用的命令
1. 新建并启动容器
$ docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
OPTIONS说明(常用):
* -d: 后台运行容器,并返回容器ID;
* --name="nginx-lb": 为容器指定一个名称;
* -i:以交互模式运行容器,通常与 -t 同时使用;
* -t:为容器重新分配一个伪输入终端,通常与 -i 同时使用;
* -P: 随机端口映射;
* -p: 指定端口映射,有以下四种格式
* ip:hostPort:containerPort
* ip::containerPort
* hostPort:containerPort
* containerPort
* --net="bridge": 指定容器的网络连接类型,支持 bridge/host/none/container:
例如:
$ docker run -d -p 91:80 nginx
2. 列出容器
$ docker ps [OPTIONS]
OPTIONS说明(常用):
* -a :显示所有的容器,包括未运行的。
* -f :根据条件过滤显示的内容。
* --format :指定返回值的模板文件。
* -l :显示最近创建的容器。
* -n :列出最近创建的n个容器。
* --no-trunc :不截断输出。
* -q :静默模式,只显示容器编号。
* -s :显示总的文件大小。
3. 停止容器
$ docker stop CONTAINER_ID/CONTAIN_NAME
4. 强制停止容器
$ docker kill CONTAINER_ID/CONTAIN_NAME
5. 启动已停止容器
$ docker start CONTAINER_ID/CONTAIN_NAME
6. 重启容器
$ docker restart CONTAINER_ID/CONTAIN_NAME
7. 进入容器
$ docker exec -it CONTAINER_ID bash
8. 删除容器
$ docker rm [OPTIONS] CONTAINER [CONTAINER...]
OPTIONS说明(常用):
* -f :通过SIGKILL信号强制删除一个运行中的容器
* -l :移除容器间的网络连接,而非容器本身
* -v :-v 删除与容器关联的卷
更多命令见Docker的官方文档:https://docs.docker.com/edge/engine/reference/commandline/
根据Harbor官方描述:
Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中, 确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。
注: 由于 Harbor 是基于 Docker Registry V2 版本,所以 docker 版本必须 > = 1.10.0 docker-compose >= 1.6.0
开源项目地址:https://github.com/vmware/harbor
1.安装python和docker-compose,查看openssl版本
[root@node1 ~]# python --version ##我使用的镜像里自带的python,版本2.7.5,满足要求
Python 2.7.5
[root@node1 ~]# yum install python-pip -y ##安装pip
[root@node1 ~]# pip install --upgrade pip ##升级以下pip
[root@node1 ~t]# pip install docker-compose ##安装docker-compose
[root@node1 ~]# pip install --upgrade docker-compose ##检测更新
[root@node1 ~]# docker-compose -v ##版本1.23.1完全满足要求
docker-compose version 1.23.1, build b02f130
[root@node1 ~]# openssl version ##凑合..........用吧,反正自己测试玩呢
OpenSSL 1.0.2k-fips 26 Jan 2017
2.使用离线方式,安装harbor,下载所需的软件包(以下需要-翻-墙-下载的地方你们自己解决吧......)
也可以下载小弟的链接:harbor-offline-installer-v1.5.4 ,提取码:9aak
[root@node1 ~]# tar -zxf harbor-offline-installer-v1.5.4.tgz
[root@node1 ~]# mv harbor /usr/local/
[root@node1 harbor]# ls
common docker-compose.clair.yml docker-compose.notary.yml docker-compose.yml ha harbor.cfg install.sh LICENSE NOTICE open_source_license prepare
3.创建自签名证书
[root@node1 harbor]# openssl genrsa -out docker.com.key 1024
saGenerating RSA private key, 1024 bit long modulus
.............................++++++
.........++++++
e is 65537 (0x10001)
[root@node1 harbor]# ls
common docker.com.key docker-compose.clair.yml docker-compose.notary.yml docker-compose.yml ha harbor.cfg harbor.cfg.bak install.sh LICENSE NOTICE open_source_license prepare
[root@node1 harbor]# openssl req -new -key docker.com.key -out docker.com.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:guangdong
Locality Name (eg, city) [Default City]:guangzhou
Organization Name (eg, company) [Default Company Ltd]:southgis
Organizational Unit Name (eg, section) []:dev dept
Common Name (eg, your name or your server's hostname) []:ray
Email Address []:[email protected]
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:southgis
[root@node1 harbor]# ls
common docker.com.csr docker.com.key docker-compose.clair.yml docker-compose.notary.yml docker-compose.yml ha harbor.cfg harbor.cfg.bak install.sh LICENSE NOTICE open_source_license prepare
[root@node1 harbor]# openssl x509 -req -days 365 -in docker.com.csr -signkey docker.com.key -out docker.com.crt
Signature ok
subject=/C=CN/ST=guagnzhou/L=/O=southgis/OU=dev dept/CN=/[email protected]
Getting Private key
[root@node1 harbor]# ll docker.com.csr docker.com.key docker.com.crt
-rw-r--r--. 1 root root 908 Nov 12 16:10 docker.com.crt
-rw-r--r--. 1 root root 741 Nov 12 16:09 docker.com.csr
-rw-r--r--. 1 root root 891 Nov 12 16:06 docker.com.key
[root@node1 harbor]# pwd
/usr/local/harbor
4.配置Harbor的配置文件
[root@node1 harbor]# vi harbor.cfg
hostname = node1 配置主机名称
ui_url_protocol = https 使用的协议
customize_crt = on 工作线程数
ssl_cert = /usr/local/harbor/docker.com.crt
ssl_cert_key = /usr/local/harbor/docker.com.key
log_rotate_size = 200M 日志最大200M
harbor_admin_password = Harbor12345 harbor的密码
db_password = root123 会自动起一个mysql容器,密码是root123
[root@node1 harbor]# ./install.sh
[Step 0]: checking installation environment ... ##检测环境
Note: docker version: 17.12.1
Note: docker-compose version: 1.23.1
[Step 1]: loading Harbor images ... ##加载镜像
ad50e89f4922: Loading layer [==================================================>] 133.4MB/133.4MB
b9111f3900ae: Loading layer [==================================================>] 23.38MB/23.38MB
4f356758d397: Loading layer [==================================================>] 20.91MB/20.91MB
bc638e648859: Loading layer [==================================================>] 20.91MB/20.91MB
Loaded image: vmware/harbor-jobservice:v1.5.4
008e13b55131: Loading layer [==================================================>] 23.38MB/23.38MB
2826ddfdc793: Loading layer [==================================================>] 15.37MB/15.37MB
d00ae9679664: Loading layer [==================================================>] 15.37MB/15.37MB
Loaded image: vmware/harbor-adminserver:v1.5.4
bf9b29f3e16d: Loading layer [==================================================>] 403.4MB/403.4MB
035dfc5fccad: Loading layer [==================================================>] 9.216kB/9.216kB
bc1076539dfb: Loading layer [==================================================>] 9.216kB/9.216kB
c431a7d41946: Loading layer [==================================================>] 7.68kB/7.68kB
eae032ece432: Loading layer [==================================================>] 1.536kB/1.536kB
655cc4bf808b: Loading layer [==================================================>] 11.78kB/11.78kB
d3abc4a9d081: Loading layer [==================================================>] 2.56kB/2.56kB
5c4a4b82fc4d: Loading layer [==================================================>] 3.072kB/3.072kB
Loaded image: vmware/harbor-db:v1.5.4
942ae0a8d99e: Loading layer [==================================================>] 83.89MB/83.89MB
520f2e0dc635: Loading layer [==================================================>] 3.072kB/3.072kB
6a18a0ec7f60: Loading layer [==================================================>] 59.9kB/59.9kB
d988f22b9f5f: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: vmware/redis-photon:v1.5.4
eac497b4b503: Loading layer [==================================================>] 5.128MB/5.128MB
Loaded image: vmware/nginx-photon:v1.5.4
853bfc76ed58: Loading layer [==================================================>] 158.1MB/158.1MB
3fd52c4887f9: Loading layer [==================================================>] 10.93MB/10.93MB
fe8ab3e87ac0: Loading layer [==================================================>] 2.048kB/2.048kB
12a0d81beb68: Loading layer [==================================================>] 48.13kB/48.13kB
fd905da838da: Loading layer [==================================================>] 10.98MB/10.98MB
Loaded image: vmware/clair-photon:v2.0.6-v1.5.4
a995a3534368: Loading layer [==================================================>] 23.38MB/23.38MB
d6cbd978280f: Loading layer [==================================================>] 24.41MB/24.41MB
5851646b723b: Loading layer [==================================================>] 7.168kB/7.168kB
8070bec65554: Loading layer [==================================================>] 10.56MB/10.56MB
6544515351b8: Loading layer [==================================================>] 24.4MB/24.4MB
Loaded image: vmware/harbor-ui:v1.5.4
Loaded image: photon:1.0
34699905595d: Loading layer [==================================================>] 23.38MB/23.38MB
cfea98e05b5d: Loading layer [==================================================>] 12.16MB/12.16MB
231f7274b72e: Loading layer [==================================================>] 17.3MB/17.3MB
7d3d139904f4: Loading layer [==================================================>] 15.87kB/15.87kB
72f72b7a3c94: Loading layer [==================================================>] 3.072kB/3.072kB
8d34d1d33f54: Loading layer [==================================================>] 29.46MB/29.46MB
Loaded image: vmware/notary-server-photon:v0.5.1-v1.5.4
Loaded image: vmware/mariadb-photon:v1.5.4
15191ee1bd9b: Loading layer [==================================================>] 73.32MB/73.32MB
c1de64e414a9: Loading layer [==================================================>] 3.584kB/3.584kB
1ca692cb7dbc: Loading layer [==================================================>] 3.072kB/3.072kB
359b1a79ec54: Loading layer [==================================================>] 4.096kB/4.096kB
849b9d327989: Loading layer [==================================================>] 3.584kB/3.584kB
eebfdeeeed02: Loading layer [==================================================>] 9.728kB/9.728kB
Loaded image: vmware/harbor-log:v1.5.4
c8a6d1eb1eae: Loading layer [==================================================>] 23.38MB/23.38MB
aa423651976e: Loading layer [==================================================>] 2.56kB/2.56kB
619529c2b555: Loading layer [==================================================>] 2.56kB/2.56kB
3f1091c751e3: Loading layer [==================================================>] 2.048kB/2.048kB
bdfa6bcc0cbc: Loading layer [==================================================>] 22.8MB/22.8MB
dc78c02b0c29: Loading layer [==================================================>] 22.8MB/22.8MB
Loaded image: vmware/registry-photon:v2.6.2-v1.5.4
c6277b5de5ab: Loading layer [==================================================>] 10.95MB/10.95MB
2a90321baeb0: Loading layer [==================================================>] 17.3MB/17.3MB
b4feb5683938: Loading layer [==================================================>] 15.87kB/15.87kB
547e893b3a73: Loading layer [==================================================>] 3.072kB/3.072kB
5b884b86445c: Loading layer [==================================================>] 28.24MB/28.24MB
Loaded image: vmware/notary-signer-photon:v0.5.1-v1.5.4
ba777a12ecc6: Loading layer [==================================================>] 95.85MB/95.85MB
57bd73ea258d: Loading layer [==================================================>] 6.656kB/6.656kB
71b26b48c755: Loading layer [==================================================>] 2.048kB/2.048kB
abad61b5ce57: Loading layer [==================================================>] 7.68kB/7.68kB
Loaded image: vmware/postgresql-photon:v1.5.4
454c81edbd3b: Loading layer [==================================================>] 135.2MB/135.2MB
e99db1275091: Loading layer [==================================================>] 395.4MB/395.4MB
051e4ee23882: Loading layer [==================================================>] 9.216kB/9.216kB
6cca4437b6f6: Loading layer [==================================================>] 9.216kB/9.216kB
1d48fc08c8bc: Loading layer [==================================================>] 7.68kB/7.68kB
0419724fd942: Loading layer [==================================================>] 1.536kB/1.536kB
543c0c1ee18d: Loading layer [==================================================>] 655.2MB/655.2MB
4190aa7e89b8: Loading layer [==================================================>] 103.9kB/103.9kB
Loaded image: vmware/harbor-migrator:v1.5.0
[Step 2]: preparing environment ... ##准备环境
Clearing the configuration file: ./common/config/adminserver/env
Clearing the configuration file: ./common/config/ui/env
Clearing the configuration file: ./common/config/ui/app.conf
Clearing the configuration file: ./common/config/ui/private_key.pem
Clearing the configuration file: ./common/config/db/env
Clearing the configuration file: ./common/config/jobservice/env
Clearing the configuration file: ./common/config/jobservice/config.yml
Clearing the configuration file: ./common/config/registry/config.yml
Clearing the configuration file: ./common/config/registry/root.crt
Clearing the configuration file: ./common/config/nginx/cert/docker.com.crt
Clearing the configuration file: ./common/config/nginx/cert/docker.com.key
Clearing the configuration file: ./common/config/nginx/nginx.conf
Clearing the configuration file: ./common/config/log/logrotate.conf
loaded secret from file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
[Step 3]: checking existing instance of Harbor ... ##检测运行环境
[Step 4]: starting Harbor ... ## 运行容器
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis ... done
Creating harbor-db ... done
Creating registry ... done
Creating harbor-adminserver ... done
Creating harbor-ui ... 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 https://node1.
For more details, please visit https://github.com/vmware/harbor .
此时访问https:node1
输入用户名:admin
输入密码:Harbor12345
就可以进去了
注意事项:
root@node1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8f2940cb239d vmware/harbor-jobservice:v1.5.4 "/harbor/start.sh" 6 minutes ago Up 6 minutes harbor-jobservice
a9ee56b44f03 vmware/nginx-photon:v1.5.4 "nginx -g 'daemon of…" 6 minutes ago Up 6 minutes (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx
ac08fe6a5b12 vmware/harbor-ui:v1.5.4 "/harbor/start.sh" 6 minutes ago Up 6 minutes (healthy) harbor-ui
a13b86e0897f vmware/harbor-adminserver:v1.5.4 "/harbor/start.sh" 6 minutes ago Up 6 minutes (healthy) harbor-adminserver
9f382ef9c6e9 vmware/registry-photon:v2.6.2-v1.5.4 "/entrypoint.sh serv…" 6 minutes ago Up 6 minutes (healthy) 5000/tcp registry
67cce021e6c1 vmware/harbor-db:v1.5.4 "/usr/local/bin/dock…" 6 minutes ago Up 6 minutes (healthy) 3306/tcp harbor-db
43b56f9fefcc vmware/redis-photon:v1.5.4 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 6379/tcp redis
63b8d5e17a85 vmware/harbor-log:v1.5.4 "/bin/sh -c /usr/loc…" 6 minutes ago Up 6 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
harbor其实也是以container的方式运行的,一共有8个容器,这8个容器在本地的存储路径是下面的那个,所以这个文件夹需要大一点,博主刚刚开始没有注意,测试机存储都是9G的,加载image的时候,就不够用了,最后饶了没办法就又加了一个硬盘,比较麻烦
[root@node1 ~]# ll /var/lib/docker/overlay2/
total 344
drwx------. 4 root root 4096 Nov 12 17:09 02938caebaf2469166f686b88ce71ce8b75f8a3164e06abadb052210241be7b6
drwx------. 4 root root 4096 Nov 12 17:09 0403016f457bbbb221339eb3f70ca1096b5ad58b15776331cd581cebe92a772b
...
...
drwx------. 4 root root 4096 Nov 12 17:08 f2ad91bc06f87b319654ec329e13b319efc827f2e92d3d23314f38e0686de411
drwx------. 4 root root 4096 Nov 12 17:09 f8049719bd92a25d48576b54f7f239803ed2655c7071e7ac0638816138a37b5d
drwx------. 4 root root 4096 Nov 12 17:09 f89afc0fa06f959fd9a78aaa606369a7bfe052e70d1994e2de85a2d0691c3b3f
drwxr-xr-x. 2 root root 4096 Nov 12 17:10 l
drwx------. 2 root root 16384 Nov 12 17:01 lost+found
harbor运行的时候可以看到使用了80/443/4443端口,所以这些端口需要空出来
[root@node1 ~]# netstat -nplt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 942/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1028/master
tcp 0 0 127.0.0.1:1514 0.0.0.0:* LISTEN 1967/docker-proxy
tcp6 0 0 :::80 :::* LISTEN 2602/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 942/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1028/master
tcp6 0 0 :::443 :::* LISTEN 2578/docker-proxy
tcp6 0 0 :::4443 :::* LISTEN 2567/docker-proxy
至此, Harbor 已经搭建完成,具体在 WEB UI 下面操作也是非常的简单,只有几个选项。
docker 需要上传 push 镜像,需要在 docker 中配置 --insecure-registry userIP
#因为docker默认使用的是https连接,而harbor默认使用http连接,所以需要修改docker配置标志insecure registry不安全仓库的主机!
#当然,harbor也可以设置为https,我这里就是设置为https的然后在/usr/lib/systemd/system/docker.service加入--insecure-registry userIP
#vi/usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --insecure-registry=XXX.XXX.XX.XXX
#只加上--insecure-registry这个参数即可。
重启docker:
$ systemctl daemon-reload
$ systemctl restart docker.service
使用 docker login userIP 登陆 Harbor
[root@swarm-manager ~]#docker login XXX.XXX.XX.XXX
Username (admin): admin
Password: Harbor12345
Login Succeeded
尝试push一个镜像到仓库中,首先在Harbor页面中新建一个私服:project
新建一个photon:1.0 192.168.43.111/project/photon:1.0镜像
[root@localhost system]# docker tag photon:1.0 192.168.43.111/project/photon:1.0
[root@localhost system]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
vmware/redis-photon v1.5.4 c7a3c332ff8f 4 months ago 210MB
vmware/clair-photon v2.0.6-v1.5.4 faf3e2f1841f 4 months ago 302MB
vmware/notary-server-photon v0.5.1-v1.5.4 f9a7e87fa884 4 months ago 209MB
vmware/notary-signer-photon v0.5.1-v1.5.4 d9c8ddb0da72 4 months ago 207MB
vmware/registry-photon v2.6.2-v1.5.4 6b4bdec4101e 4 months ago 196MB
vmware/nginx-photon v1.5.4 ef99f7e61229 4 months ago 132MB
vmware/harbor-log v1.5.4 13ae381fcfc5 4 months ago 198MB
vmware/harbor-jobservice v1.5.4 aea9fd3c3fc0 4 months ago 192MB
vmware/harbor-ui v1.5.4 a947b8b53a8f 4 months ago 209MB
vmware/harbor-adminserver v1.5.4 d9ead0ee5c4a 4 months ago 181MB
vmware/harbor-db v1.5.4 17cc3586bcd3 4 months ago 525MB
vmware/mariadb-photon v1.5.4 446d2083018d 4 months ago 525MB
vmware/postgresql-photon v1.5.4 0f4f752b7a90 4 months ago 219MB
192.168.43.111/project/photon 1.0 03c1901c3cd5 4 months ago 127MB
photon 1.0 03c1901c3cd5 4 months ago 127MB
vmware/harbor-migrator v1.5.0 466c57ab0dc3 9 months ago 1.16GB
push上私服
[root@localhost system]# docker push 192.168.43.111/project/photon:1.0
The push refers to repository [192.168.43.111/project/photon]
ad50e89f4922: Pushed
1.0: digest: sha256:2336c23b341da8853d48f5e9234c1f3fa914db2acc773996fb0fbde33e57bb1c size: 529
[root@localhost system]# docker pull 192.168.43.111/project/photon:1.0
1.0: Pulling from project/photon
Digest: sha256:2336c23b341da8853d48f5e9234c1f3fa914db2acc773996fb0fbde33e57bb1c
Status: Image is up to date for 192.168.43.111/project/photon:1.0
此时,私服上就有一个镜像了
稿毕!!!!!!!!!!!!!!!!!!!!!