学习写代码呀

导航

搭建docker-harbor步骤

一、下载并安装配置docker (新版本已经到20.10.14)

wget -qO- https://get.docker.com | sh或者 yum -y install docker

推荐:yum install docker-ce

安装新版本docker:
yum配置阿里源:
/etc/yum.repos.d/
用来放指定yum仓库服务器的文件,命名成repo结尾
可以新建一个repo文件或者直接修改CentOS-Base.repo
下面是清华大学镜像仓库配置
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

或者阿里云Yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

查看docker 版本:yum list docker-ce --showduplicates | sort -r
另一种方式:
yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
# 设置 yum 源为 稳定的版本  
# 阿里的源,国内使用较快
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache
# 如果要安装指定的版本
yum list docker-ce --showduplicates | sort -r
# 填入版本号到下面的命令(docker-ce-19.03.0-3.el7)
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

# 安装最新稳定版本 Docker CE
yum install docker-ce docker-ce-cli containerd.io 

设置开机自启动:
systemctl enable docker

配置daemon.json里面的镜像仓库:
vi /etc/docker/daemon.json
一个常用的配置实例如下:

{
"registry-mirrors":[
"https://d8b3zdiw.mirror.aliyuncs.com"
],
 
"insecure-registries": [
"https://ower.site.com"
],
}
然后重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl status docker
解决普通用户需要sudo问题:
Got permission denied while trying to connect to the Docker daemon socket at
将用户添加到docker用户组可以将sudo去掉
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组
groups查看当前用户所在的用户组

docker info 查看是否配置好了

二、安装docker-compose

Docker Compose 是 Docker 官方编排(Orchestration)项目之一,负责快速在集群中部署分布式应用。Dockerfile 可以让用户管理一个单独的应用容器;而 Compose 则允许用户在一个模板(YAML 格式)中定义一组相关联的应用容器(被称为一个 project,即项目),例如一个 Web 服务容器再加上后端的数据库服务容器等。根据docker的API编写。但是是单独的项目,所以需要单独安装。

下载命令:

 curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

然后:chmod a+x /usr/local/bin/docker-compose

docker-compose --version 看版本

docker-compose version 1.13.0, build 1719ceb

 低版本不兼容harbor,需要高版本:

curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

 

三、安装harbor

离线下载和在线安装两种

这里用的离线下载:

https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz

tar -zxvf harbor-offline-installer-v2.5.0.tgz

cp harbor.yml.tmpl harbor.yml

vi harbor.yml

测试配置hostname为ip:192.168.59.133

注释掉https证书配置

加上:harbor_admin_password: harbor123456

然后:./install.sh

./install.sh  --with-clair  --with-clair参数是启用漏洞扫描功能,新版本不需要了。

查看安装完毕:
 docker-compose ps 或者 docker ps | grep harbor

 

 harbor组件:

goharbor/harbor-exporter              v2.5.0                   36396f138dfb   13 days ago    86.7MB
goharbor/chartmuseum-photon           v2.5.0                   eaedcf1f700b   13 days ago    225MB
goharbor/redis-photon                 v2.5.0                   1e00fcc9ae63   13 days ago    156MB
goharbor/trivy-adapter-photon         v2.5.0                   4e24a6327c97   13 days ago    164MB
goharbor/notary-server-photon         v2.5.0                   6d5fe726af7f   13 days ago    112MB
goharbor/notary-signer-photon         v2.5.0                   932eed8b6e8d   13 days ago    109MB
goharbor/harbor-registryctl           v2.5.0                   90ef6b10ab31   13 days ago    136MB
goharbor/registry-photon              v2.5.0                   30e130148067   13 days ago    77.5MB
goharbor/nginx-photon                 v2.5.0                   5041274b8b8a   13 days ago    44MB
goharbor/harbor-log                   v2.5.0                   89fd73f9714d   13 days ago    160MB
goharbor/harbor-jobservice            v2.5.0                   1d097e877be4   13 days ago    226MB
goharbor/harbor-core                  v2.5.0                   42a54bc05b02   13 days ago    202MB
goharbor/harbor-portal                v2.5.0                   c206e936f4f9   13 days ago    52.3MB
goharbor/harbor-db                    v2.5.0                   d40a1ae87646   13 days ago    223MB
goharbor/prepare                      v2.5.0                   36539574668f   13 day




 

posted on 2022-04-21 10:11  学习写代码呀  阅读(550)  评论(0编辑  收藏  举报