docker私有仓库Harbor的搭设与使用
Posted liumangchen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker私有仓库Harbor的搭设与使用相关的知识,希望对你有一定的参考价值。
1、Harbor 介绍
Manage and serve container images in a secure environment
2、环境、软件准备
Linux Centos7上操作,以下是安装的软件及版本:
Centos:Linux version 3.10.0-862.9.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Mon Jul 16 16:29:36 UTC 2018
Docker:version 18.09.0, build 4d60db4
Docker-compose:version 1.24.0, build 0aa59064
Harbor: version 1.6.2
3、Harbor搭建
采用docker-compose的方式搭建。
1)下载安装包
在线安装包:
1 wget https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-online-installer-v1.6.2.tgz 2 tar -xvf harbor-online-installer-v1.6.2.tgz
离线安装包:
1 wget https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-offline-installer-v1.6.2.tgz 2 tar -xvf harbor-offline-installer-v1.6.2.tgz
离线安装包解压后文件:
[[email protected] harbor]# ls -l total 651412 drwxr-xr-x 4 root root 4096 Dec 1 02:08 common -rw-r--r-- 1 root root 813 Nov 19 15:02 docker-compose.chartmuseum.yml -rw-r--r-- 1 root root 863 Nov 19 15:02 docker-compose.clair.yml -rw-r--r-- 1 root root 1258 Nov 19 15:02 docker-compose.notary.yml -rw-r--r-- 1 root root 3681 Dec 1 02:06 docker-compose.yml drwxr-xr-x 3 root root 4096 Nov 19 15:02 ha -rw-r--r-- 1 root root 7904 May 15 08:34 harbor.cfg -rw-r--r-- 1 root root 665406909 Nov 19 15:02 harbor.v1.6.2.tar.gz -rwxr-xr-x 1 root root 6162 May 15 08:29 install.sh -rw-r--r-- 1 root root 10768 Nov 19 15:02 LICENSE -rw-r--r-- 1 root root 482 Nov 19 15:02 NOTICE -rw-r--r-- 1 root root 1535603 Nov 19 15:02 open_source_license -rwxr-xr-x 1 root root 39132 Nov 19 15:02 prepare
2)配置参数
打开harbor.cfg文件
## Configuration file of Harbor #This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY! _version = 1.6.0 #The IP address or hostname to access admin UI and registry service. #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. hostname = 119.**.**.**
##The initial password of Harbor admin, only works for the first time when Harbor starts. #It has no effect after the first launch of Harbor. #Change the admin password from UI after launching Harbor. harbor_admin_password = 自己的密码
主要要修改hostname和admin账号密码
hostname直接输入服务器的ip地址,及时harbor分配的端口号不为80端口,例如分配端口为8080,也不要在这里写成119.**.**.**:8080。
3)安装
运行harbor文件夹里的install.sh
./install.sh
安装好后即自动启动,可访问119.**.**.**:8080,注册harbor账号。
4)添加信任
搭建的harbor暂时只用http,docker login后会提示:
Error response from daemon: Get https://172.16.103.99:1180/v1/users/: http: server gave HTTP response to HTTPS client
需要在docker启动文件中添加--insecure-registry信任关系
$ sudo touch /etc/docker/daemon.json && sudo chmod 777 /etc/docker/daemon.json && sudo echo ‘{ "insecure-registries": ["192.168.99.1:5000"] }‘ > /etc/docker/daemon.json
然后重启docker
$ systemctl restart docker
4、使用Harbor
1)输入docker login登陆
2)给要上传到harbor的docker镜像加tag
[[email protected] harbor]# docker tag build_test:latest build_test:v1
3)push镜像
[[email protected] harbor]# docker push 119.**.**.**:8080/zhouenxian/build_test:v1
以上是关于docker私有仓库Harbor的搭设与使用的主要内容,如果未能解决你的问题,请参考以下文章