构建docker企业私有仓库及Harbor实战

环境:
一台正常的docker服务器

一、pull仓库软件 - registry

[root@localhost ~]# docker pull docker.io/registry
Using default tag: latest
Trying to pull repository docker.io/library/registry ... 
latest: Pulling from docker.io/library/registry
cbdbe7a5bc2a: Pull complete 
47112e65547d: Pull complete 
46bcb632e506: Pull complete 
c1cc712bcecd: Pull complete 
3db6272dcbfa: Pull complete 
Digest: sha256:8be26f81ffea54106bae012c6f349df70f4d5e7e2ec01b143c46e2c03b9e551d
Status: Downloaded newer image for docker.io/registry:latest

[root@localhost ~]# docker images|grep registry
docker.io/registry   latest              2d4f4b5309b1        7 weeks ago         26.2 MB

二、新建仓库目录

[root@localhost ~]# mkdir -p /data/registry

三、启动仓库

[root@localhost ~]# docker run -itd --privileged -p 5000:5000 -v /data/registry:/var/lib/registry --restart=always --name=registry_5000port  docker.io/registry
ab497e98b8a09a5984e444e82046391ee70b343f2e1eaf2b2f42ffcac8310e0c

测试器测试结果
在这里插入图片描述

四、客户端配置仓库

vim /etc/sysconfig/docker
–insecure-registry 192.168.1.12:5000

[root@localhost ~]# vim /etc/sysconfig/docker
# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 192.168.1.12:5000'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi
#

五、客户端上传、下载镜像

上传一个centos8镜像至仓库

1、伪装 - 改tag信息
[root@localhost ~]# docker images|grep centos6
centos6_ssh          latest              efd998bd6817        6 years ago         297 MB

[root@localhost ~]# docker tag efd998bd6817 192.168.1.12:5000/centos6_ssh
[root@localhost ~]# docker images|grep centos6                           
192.168.1.12:5000/centos6_ssh   latest              efd998bd6817        6 years ago         297 MB
centos6_ssh                     latest              efd998bd6817        6 years ago         297 MB
2、上传 - push
[root@localhost ~]# docker push 192.168.1.12:5000/centos6_ssh
The push refers to a repository [192.168.1.12:5000/centos6_ssh]
5f70bf18a086: Pushed 
5dde9e7abaae: Pushed 
0d2c9d3bef41: Pushed 
26231980c1a5: Pushed 
7ec2a9eb1017: Pushed 
29e0db08def6: Pushed 
9225ac3d0295: Pushed 
0f26de94dce0: Pushed 
821f107b9dc4: Pushed 
latest: digest: sha256:18d681aed592b9061e6358645e1c4d0f46a4b80a63f1628f63bdf7aa6b42f3e2 size: 3019
3、在服务器端查看上传结果
[root@localhost ~]# ls /data/registry/docker/registry/v2/repositories/
centos6_ssh
[root@localhost ~]# curl -XGET http://192.168.1.12:5000/v2/_catalog
{"repositories":["centos6_ssh"]}
[root@localhost ~]# 
[root@localhost ~]# curl -XGET http://192.168.1.12:5000/v2/centos6_ssh/tags/list
{"name":"centos6_ssh","tags":["latest"]}
4、下载 pull
[root@localhost ~]# docker pull 192.168.1.12:5000/centos6_ssh:latest
Trying to pull repository 192.168.1.12:5000/centos6_ssh ... 
latest: Pulling from 192.168.1.12:5000/centos6_ssh
4f4fb700ef54: Pull complete 
22aa74e407fb: Pull complete 
af486a0a979b: Pull complete 
71899e3e76d0: Pull complete 
d9a0675e81d8: Pull complete 
f3e489d2c920: Pull complete 
ccc4b0ee49d1: Pull complete 
2eea875c5ec9: Pull complete 
ff27d4260cec: Pull complete 
Digest: sha256:18d681aed592b9061e6358645e1c4d0f46a4b80a63f1628f63bdf7aa6b42f3e2
Status: Downloaded newer image for 192.168.1.12:5000/centos6_ssh:latest

[root@localhost ~]# docker images|grep centos6
192.168.1.12:5000/centos6_ssh   latest              efd998bd6817        6 years ago         297 MB

六:Harbor

Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution
Harbor仓库部署两种方式,一种是off-line ,一种是on-line,即离线和在线安装,此处选择离线安装:
1、安装

安装环境

[root@localhost ~]# yum install epel-release -y
[root@localhost ~]# yum install python-pip -y
[root@localhost ~]# pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5a/4a/39400ff9b36e719bdf8f31c99fe1fa7842a42fa77432e584f707a5080063/pip-20.2.2-py2.py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 330kB/s 
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
      Successfully uninstalled pip-8.1.2
Successfully installed pip-20.2.2
[root@localhost ~]# pip install docker-compose
......
Successfully installed attrs-19.3.0 backports.shutil-get-terminal-size-1.0.0 bcrypt-3.1.7 cached-property-1.5.1 certifi-2020.6.20 cffi-1.14.1 chardet-3.0.4 configparser-4.0.2 contextlib2-0.6.0.post1 cryptography-3.0 distro-1.5.0 docker-4.3.0 docker-compose-1.26.2 dockerpty-0.4.1 docopt-0.6.2 enum34-1.1.10 functools32-3.2.3.post2 idna-2.10 importlib-metadata-1.7.0 jsonschema-3.2.0 paramiko-2.7.1 pathlib2-2.3.5 pycparser-2.20 pynacl-1.4.0 pyrsistent-0.16.0 python-dotenv-0.14.0 requests-2.24.0 scandir-1.10.0 subprocess32-3.5.4 texttable-1.6.2 typing-3.7.4.3 urllib3-1.25.10 websocket-client-0.57.0 zipp-1.2.0

下载Habor并且解压

[root@localhost ~]# wget -c https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.0.tgz
[root@localhost ~]# tar -zxvf harbor-offline-installer-v1.7.0.tgz 
[root@localhost ~]# cd harbor

vim harbor.cfg

[root@localhost harbor]# vim harbor.cfg 
  4 _version = 1.7.0
  5 #The IP address or hostname to access admin UI and registry service.
  6 #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
  7 #DO NOT comment out this line, modify the value of "hostname" directly, or the installation will fail.
  8 hostname = 192.168.1.112
  9 
 10 #The protocol for accessing the UI and token/notification service, by default it is http.
 11 #It can be set to https if ssl is enabled on nginx.
 12 ui_url_protocol = http
 13 
 14 #Maximum number of job workers in job service  
 15 max_job_workers = 10 

安装

[root@localhost harbor]# ./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 1.13.1
......
Creating nginx              ... done

✔ ----Harbor has been installed and started successfully.----

浏览器登录

http://192.168.1.112 用户名:admin 密码:Harbor12345,也可以在habor.cnf自己设置密码
在这里插入图片描述
创建用户
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
添加仓库 添加镜像完毕

--------------------end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值