1.关闭防火墙
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
2.设置yum源和安装docker
cd /etc/yum.repos.d/
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install epel-release
yum install -y docker
安装成后修改配置文件
vim /etc/sysconfig/docker
此版本docker默认是开启容器的selinux,所以要注释掉之前的
注释掉其他项,然后添加下面一句,IP为虚拟机的网络IP地址
OPTIONS='--insecure-registry 192.168.1.4'
启动docker
systemctl start docker
docker pull busybox 下载busybox镜像
docker images
3.安装docker-compose
cd /usr/local/bin/
curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
下载完成后添加执行权限
chmod +x /usr/local/bin/docker-compose
接着检查安装的版本是否成功
docker-compose --version
docker-compose version 1.13.0, build 1719ceb
看到版本正是1.13,这个版本可以选择很多,比如新的1.17.0版本就可以用下载的命令
curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
命令docker-compose down -v 停止harbor服务
docker-compose up -d 启动harbor服务
4.安装harbor服务
cd /usr/local/
wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgz
tar zxf harbor-offline-installer-v1.1.2.tgz
进入目录修改配置
cd harbor/
vim harbor.cfg
#只需修改hostname的ip即可,我的服务器存储卷在/home/目录下,我将数据目录更改。其他可以保持默认,默认登录密码Harbor12345
hostname = 192.168.0.40
ui_url_protocol = http
db_password = root123
max_job_workers = 3
customize_crt = on
ssl_cert = /home/harbor/data/cert/server.crt //更改目录
ssl_cert_key = /home/harbor/data/cert/server.key //更改目录
secretkey_path = /home/harbor/data //更改目录
admiral_url = NA
email_identity =
email_server = smtp.mydomain.com
email_server_port = 25
email_username = [email protected]
email_password = abc
email_from = admin
email_ssl = false
harbor_admin_password = Harbor12345
auth_mode = db_auth
ldap_url = ldaps://ldap.mydomain.com
ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com
ldap_search_pwd = password
ldap_basedn = ou=people,dc=mydomain,dc=com
ldap_filter = (objectClass=person)
ldap_uid = uid
ldap_scope = 3
ldap_timeout = 5
self_registration = on
token_expiration = 30
project_creation_restriction = everyone
verify_remote_cert = on
5.更改镜像存储目录
修改docker-compose.yml文件
[root@harbor harbor]# vim docker-compose.yml //修改harbor目录下docker-compose.yml
version: '2'
services:
log:
image: vmware/harbor-log:v1.5.0
container_name: harbor-log
restart: always
volumes:
- /var/log/harbor/:/var/log/docker/:z
- ./common/config/log/:/etc/logrotate.d/:z
ports:
- 127.0.0.1:1514:10514
networks:
- harbor
registry:
image: vmware/registry-photon:v2.6.2-v1.5.0
container_name: registry
restart: always
volumes:
- /mnt/harbordata/registry:/storage:z //更改harbor存储目录
- ./common/config/registry/:/etc/registry/:z
networks:
- harbor
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"
mysql:
image: vmware/harbor-db:v1.5.0
container_name: harbor-db
restart: always
volumes:
- /mnt/harbordata/database:/var/lib/mysql:z //更改harbor存储目录
networks:
- harbor
env_file:
- ./common/config/db/env
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "mysql"
adminserver:
image: vmware/harbor-adminserver:v1.5.0
container_name: harbor-adminserver
env_file:
- ./common/config/adminserver/env
restart: always
volumes:
- /mnt/harbordata/config/:/etc/adminserver/config/:z //更改harbor存储目录
- /mnt/harbordata/secretkey:/etc/adminserver/key:z //更改harbor存储目录
- /mnt/harbordata/:/data/:z //更改harbor存储目录
networks:
- harbor
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "adminserver"
ui:
image: vmware/harbor-ui:v1.5.0
container_name: harbor-ui
env_file:
- ./common/config/ui/env
restart: always
volumes:
- ./common/config/ui/app.conf:/etc/ui/app.conf:z
- ./common/config/ui/private_key.pem:/etc/ui/private_key.pem:z
- ./common/config/ui/certificates/:/etc/ui/certificates/:z
- /mnt/harbordata/secretkey:/etc/ui/key:z //更改harbor存储目录
- /mnt/harbordata/ca_download/:/etc/ui/ca/:z //更改harbor存储目录
- /mnt/harbordata/psc/:/etc/ui/token/:z //更改harbor存储目录
networks:
- harbor
depends_on:
- log
- adminserver
- registry
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "ui"
jobservice:
image: vmware/harbor-jobservice:v1.5.0
container_name: harbor-jobservice
env_file:
- ./common/config/jobservice/env
restart: always
volumes:
- /mnt/harbordata/job_logs:/var/log/jobs:z //更改harbor存储目录
- ./common/config/jobservice/config.yml:/etc/jobservice/config.yml:z
networks:
- harbor
depends_on:
- redis
- ui
- adminserver
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "jobservice"
redis:
image: vmware/redis-photon:v1.5.0
container_name: redis
restart: always
volumes:
- /mnt/harbordata/redis:/data //更改harbor存储目录
networks:
- harbor
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "redis"
proxy:
image: vmware/nginx-photon:v1.5.0
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx:z
networks:
- harbor
ports:
- 80:80
- 443:443
- 4443:4443
depends_on:
- mysql
- registry
- ui
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "proxy"
networks:
harbor:
external: false
[root@harbor harbor]# ./install.sh
6.访问网页
访问192.168.0.10