5

docker镜像仓库harbor的搭建与使用

 1 year ago
source link: https://bajie.dev/posts/20221219-docker_harbor/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Docker镜像仓库harbor的搭建与使用

2022-12-19 2 分钟阅读

一:我们在公司内部建立了Docker内部镜像仓库:

harbor是vmware出的一个docker镜像仓库,本质是一组容器的集合体,算是一个多容器的pod.

数据卷缺省是宿主机的/data,所以我们把iscsiu挂在/data

主机:172.18.31.28

首先安装docker-ce

添加docker-ce源:

yum install epel-release

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum install docker-ce -y

yum install ntp -y

启动自动同步时间:

timedatectl set-ntp yes  #此处可用yes,no,1或0

配置时区:

timedatectl set-timezone Asia/Shanghai

配置Docker启动参数:

mkdir -p /etc/docker
cat << EOF >> /etc/docker/daemon.json
{
    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
EOF

之后装的所有Docker的宿主机,如果要用到这个私有仓库的话:

cat << EOF >> /etc/docker/daemon.json
{
     "insecure-registries":["172.18.31.28"],
     "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
EOF

启动docker

systemctl enable docker && systemctl start docker

​ 安装Docker-compose

yum install docker-compose
pip3 install -I requests==2.9 来强制修正

下载harbor的离线安装包

cd /root
https://github.com/goharbor/harbor/releases/download/v2.0.1/harbor-offline-installer-v2.0.1.tgz
tar zxvf harbor-offline-installer-v2.0.1-rc1.tgz
cd harbor

编辑配置文件:

cp harbor.yml.tmpl harbor.yml
vi harbor.yml
    hostname: 172.18.31.28
	harbor_admin_password: Fuckxxxbbaasskk
	隐掉443,因为我们是内网用,配个证书也是假的,所以关了443
	#https:
    # https port for harbor, default is 443
    #  port: 443
    # The path of cert and key files for nginx
    #  certificate: /your/certificate/path
	换掉DB的pass
	database:
    # The password for the root user of Harbor DB. Change this before any production use.
      password: xxxxxxx
    #  private_key: /your/private/key/path

然后直接安装:

./install.sh

安装完成了就,看一眼:

docker-compose ps
2020-07-08_092524.png

然后直接登录 http://172.18.31.28 就好

2020-07-08_092910.png

缺省有一个library的开放项目,我们推一个busybox过去测试一下:

首先拉一个busybox到本地
docker pull busybox

打个tag
docker tag busybox:latest 172.18.31.28/library/busybox

推上去
docker push 172.18.31.28/library/busybox

这时候再去31.28的library项目里看,就能看到新推上去的busybox镜像了

在其他的机器上,首先登录,然后就可以拉镜像了。

2020-08-17_113331.png

再举个实际例子,我们把metallb给推上去备用:

打tag
docker tag docker.io/metallb/controller:v0.9.3 172.18.31.28/library/docker.io/metallb/controller:v0.9.3

推上去
docker push 172.18.31.28/library/docker.io/metallb/controller:v0.9.3

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK