CentOS7.3安装配置Harbor全过程

前端之家收集整理的这篇文章主要介绍了CentOS7.3安装配置Harbor全过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文从安装完成Centos7.3开始记录,直到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

应用网络配置

$ systemctl restart network

解决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

下载wget

$ yum install -y wget

配置阿里云镜像

$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
$ yum clean all
$ yum makecache

下载安装docker

$ yum install docker

下载安装vim

$ yum install -y vim

下载安装扩展源epel

$ sudo yum -y install epel-release

下载安装python-pip

$ yum install python-pip

下载安装docker-compose

$ pip install docker-compose

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

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

修改docker-compose.yml配置文件

$ vim docker-compose.yml
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"

修改harbor.cfg配置文件

$ vim harbor.cfg
## Configuration file of Harbor
## 其他都不修改
hostname = 172.16.22.76

使用官方自带脚本更新参数

$ ./prepare

执行./install.sh 自动进行安装

$ ./install.sh

安装完成后访问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

重启docker会报错,修改 /etc/docker/daemon.json

{
  "registry-mirrors": ["http://9e054c8b.m.daocloud.io"],"insecure-registries": [] }

在项目中标记镜像

// 首先拉取一个MysqL镜像作为测试
$ docker pull MysqL:5.7
$ docker tag daocloud.io/MysqL:5.7 172.16.22.76/demo-project/MysqL:5.7

登陆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

由于https原因登陆报错,修改docker配置文件

$ vi /etc/sysconfig/docker
## 追加参数 --insecure-registry 172.16.22.76
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 172.16.22.76'

推送镜像到harbor仓库

$ docker push 172.16.22.76/demo-project/hnnp-MysqL:5.7
原文链接:https://www.f2er.com/centos/374646.html

猜你在找的CentOS相关文章