Harbor安装教程

配置网络

$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPADDR=172.16.22.76
GATEWAY=172.16.22.1
NETMASK=255.255.255.128
DNS1=8.8.8.8
DNS2=8.8.4.4
ONBOOT=YES
BOOTPROTO=static
1
2
3
4
5
6
7
8
9
应用网络配置

$ systemctl restart network
1
解决yum源无法更新和下载软件,增加163源 
http://mirrors.163.com/.help/centos.html

// 备份默认源
$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

// 下载 CentOS7-Base-163.repo 并放入 /etc/yum.repos.d/ 目录下
$ yum clean all
$ yum makecache
1
2
3
4
5
6
下载wget

$ yum install -y wget
1
配置阿里云镜像

$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
$ yum clean all
$ yum makecache
1
2
3
下载安装docker

$ yum install docker
1
下载安装vim

$ yum install -y vim
1
下载安装扩展源epel

$ sudo yum -y install epel-release
1
下载安装python-pip

$ yum install python-pip
1
下载安装docker-compose

$ pip install docker-compose
1
离线安装Harbor 
官网下载并拷贝harbor-offline-installer-v1.4.0_2.tgz到home目录下并解压

$ tar zxvf harbor-offline-installer-v1.4.0_2.tgz
// 解压完成后进入harbor目录修改配置文件
$ cd /home/harbor/
1
2
3
修改docker-compose.yml配置文件

$ vim docker-compose.yml
1
version: '2'
services:
  log:
    image: vmware/harbor-log:v1.4.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.4.0
    container_name: registry
    restart: always
    volumes:
      - /data/registry:/storage:z
      - ./common/config/registry/:/etc/registry/:z
    networks:
      - harbor
    ports:
      - 5000:5000 // 只增加这一行配置
    environment:
      - GODEBUG=netdns=cgo
    command:
      ["serve", "/etc/registry/config.yml"]
    depends_on:
      - log
    logging:
      driver: "syslog"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
修改harbor.cfg配置文件

$ vim harbor.cfg
1
## Configuration file of Harbor
## 其他都不修改
hostname = 172.16.22.76
1
2
3
使用官方自带脚本更新参数

$ ./prepare
1
执行./install.sh 自动进行安装

$ ./install.sh
1
安装完成后访问172.16.22.76 使用admin Harbor12345 进行登陆管理并创建demo-project公开项目

使用国内docker仓库镜像

$ curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://9e054c8b.m.daocloud.io
1
重启docker会报错,修改 /etc/docker/daemon.json 为

{
  "registry-mirrors": ["http://9e054c8b.m.daocloud.io"],
  "insecure-registries": []
}
1
2
3
4
在项目中标记镜像

// 首先拉取一个mysql镜像作为测试
$ docker pull mysql:5.7
$ docker tag daocloud.io/mysql:5.7 172.16.22.76/demo-project/mysql:5.7
1
2
3
登陆Harbor

$ docker login 172.16.22.76
Username:admin
Password:Harbor12345
Error response from daemon: Get https://172.16.22.76/v1/users/: dial tcp 172.16.22.76:443: getsockopt: connection refused
1
2
3
4
由于https原因登陆报错,修改docker配置文件

$ vi /etc/sysconfig/docker
1
## 追加参数 --insecure-registry 172.16.22.76
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 172.16.22.76'
1
2
推送镜像到harbor仓库

重启Harbor命令:docker-compose start | stop | restart

你可能感兴趣的:(Harbor安装教程)