需要先安装docker和docker-compose,下面是安装docker-compose的方法:
yum -y install epel-release
yum -y install python-pip
pip --version
pip install docker-compose
下面是安装Harbor的详细流程:
[root@cd010 local]# wget
https://github.com/vmware/harbor/releases/download/0.5.0/harbor-offline-installer-0.5.0.tgz
[root@cd010 local]# tar zxvf harbor-offline-installer-0.5.0.tgz
修改harbor目录下harbor.cfg文件,其中hostname必须改
修改docker-compose.yml中,registry容器的ports,修改之后内容如下:
registry:
image: library/registry:2.5.0
container_name: registry
restart: always
volumes:
- /data/registry:/storage
- ./common/config/registry/:/etc/registry/
ports:
- 5000:5000
environment:
- GODEBUG=netdns=cgo
command:
["serve", "/etc/registry/config.yml"]
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "registry"
更改/etc/sysconfig/docker文件配置,OPTIONS里添加--insecure-registry 10.10.3.12:5000
OPTIONS='--insecure-registry 10.10.3.12:5000 --selinux-enabled -H tcp://0.0.0.0:28015 -H unix:///var/run/docker.sock --signature-verification=false --log-driver=journald'
[root@cd010 local]# ./install.sh
如果出现以下错误,尝试把34.193.147.40 registry-1.docker.io auth.docker.io追加到/etc/hosts文件中,然后再重新安装一遍试试
[Step 4]: starting Harbor ...
Pulling registry (library/registry:2.5.0)...
Trying to pull repository docker.io/library/registry ...
ERROR: Get https://registry-1.docker.io/v2/library/registry/manifests/2.5.0: Get https://auth.docker.io/token?scope=repository:library/registry:pull&service=registry.docker.io: read tcp 10.10.3.12:59995->50.17.62.194:443: read: connection reset by peer
下面是正确安装的完整日志:
[root@cd010 harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 1.12.5
Note: docker-compose version: 1.11.2
[Step 1]: loading Harbor images ...
Loaded image: vmware/harbor-log:0.5.0
Loaded image: vmware/harbor-db:0.5.0
Loaded image: vmware/harbor-jobservice:0.5.0
Loaded image: nginx:1.11.5
Loaded image: registry:2.5.0
Loaded image: photon:1.0
Loaded image: vmware/harbor-ui:0.5.0
[Step 2]: preparing environment ...
loaded secret key
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/app.conf
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/nginx.conf
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/ui/app.conf
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/app.conf
Generated configuration file: ./common/config/ui/private_key.pem
Generated configuration 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 ...
Pulling registry (library/registry:2.5.0)...
Trying to pull repository docker.io/library/registry ...
2.5.0: Pulling from docker.io/library/registry
Digest: sha256:1b68f0d54837c356e353efb04472bc0c9a60ae1c8178c9ce076b01d2930bcc5d
Creating harbor-log
Creating registry
Creating harbor-ui
Creating harbor-db
Creating harbor-jobservice
Creating nginx
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://172.16.13.113.
For more details, please visit https://github.com/vmware/harbor .
[root@cd010 harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dfe6a38df8ac vmware/harbor-jobservice:0.5.0 "/harbor/harbor_jobse" About an hour ago Up About an hour harbor-jobservice
b69b9e5368f9 nginx:1.11.5 "nginx -g 'daemon off" About an hour ago Up About an hour 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp nginx
645007690ed1 vmware/harbor-ui:0.5.0 "/harbor/harbor_ui" About an hour ago Up About an hour harbor-ui
e1959ccde630 vmware/harbor-db:0.5.0 "docker-entrypoint.sh" About an hour ago Up About an hour 3306/tcp harbor-db
dc01bc793a42 library/registry:2.5.0 "/entrypoint.sh serve" About an hour ago Up About an hour 5000/tcp registry
a7aa466426c2 vmware/harbor-log:0.5.0 "/bin/sh -c 'crond &&" About an hour ago Up About an hour 0.0.0.0:1514->514/tcp harbor-log
a1dc3931fab1 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 7 hours ago Up 7 hours k8s_POD.165f7952_kube-dns-v81-9ztos_kube-system_f4275beb-04e9-11e7-adcf-fa163e6c1738_af0b8e17
c0f1c22fe054 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 8 hours ago Up 8 hours k8s_POD.36030bb2_redis-master-pep6z_default_29aa7e25-fd55-11e6-a1db-fa163e6c1738_3770211a
完成以后,可以使用 http://hostname 访问 Harbor,使用账号admin/Harbor12345登录
通过浏览器登录之后可以创建一个项目,比如test
docker tag nginx:1.11.5 10.10.3.12:5000/test/nginx:1.11.5
docker push 10.10.3.12:5000/test/nginx:1.11.5
注意docker push时的格式为userip:port/项目名/image名字:版本号。如果格式不对,push时会出现下面错误:
[root@cd010 harbor]# docker push 10.10.3.12:5000/nginx:1.11.5
The push refers to a repository [10.10.3.12:5000/nginx]
3f117c44afbb: Preparing
c4a8b7411af4: Preparing
unauthorized: authentication required
